For years, advocates of the lean web have lamented that there's no such thing as HTML imports—me included. But turns out, you probably don't actually need them. Let's dig in! JS and CSS have them. Why not HTML?In JavaScript, you can import one JS file into another using the
In CSS, you use
For a brief moment, there was a spec in the works to do the same thing with HTML, like this…
It was scrapped. HTML imports would have enabled you to build more moderately sized websites with just HTML, CSS, and JS: no generator or CMS or build system required. A lot of us were pretty disappointed about this. But in reality, you probably don't need them.I just learned that for literally decades Apache has had a feature called _Server Side Includes (or SSI)_. I works more-or-less just like the scrapped HTML import spec.
While it started as an Apache server thing, it's also supported in LiteSpeed, nginx, IIS and Jigsaw. You also import HTML with PHP. Instead of ending your HTML file with the It can still be mostly HTML. We only need the
But because PHP is a programming language, you could The server is better than the browser.The advantage with all of these approaches over a native HTML import is that it all happens on the server, so you're not waiting for an HTML file waterfall to complete before rendering. In my opinion, that makes SSI and PHP a better approach than native HTML imports would be… and it's available already today! Cheers, Want to share this with others or read it later? View it in a browser. |
0 Komentar untuk "[Go Make Things] You probably dont need HTML imports"