Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import HTML document using HTML link rel

I am trying to import an HTML document into my main document using

<link rel="import" href="my-tabs.html">

but it doesn't seem to be working.

I am following this presentation, using Chrome 28, and I have enabled these two flags in about:flags:

Enable experimental WebKit features
Enable experimental JavaScript

Am I missing something? or is there another flag I need to enable to get it?

like image 402
kongaraju Avatar asked Jul 12 '13 10:07

kongaraju


1 Answers

For latecomers:

As of 2021, HTML imports feature has been deprecated (MDN Link).

Due to uncertainty about this feature, I would not recommend its usage.

My recommendation: Add a data- attribute to html imports. Write a script that runs on all those elements with that attribute and access those html parts using fetch() in the script. Create a div and add that fetched import to that div at the same place. Essentially, add some JS based post processing that will download the html and inset into the same place as the import, replacing it.

like image 177
Nitin Jadhav Avatar answered Oct 19 '22 10:10

Nitin Jadhav