Issue link: https://read.uberflip.com/i/1146286
The Best of Both Worlds
|
61
Dynamic Inlining
http://stevesouders.com/hpws/dynamic-inlining.php
Since every user starts off without the cookie, there has to be a way to bootstrap the
process. This is accomplished by using the post-onload download technique from
the previous example. The first time a user visits the page, the server sees that the
cookie is absent and it generates a page that inlines the components. The server then
adds JavaScript to dynamically download the external files (and set a cookie) after
the page has loaded. The next time the page is visited, the server sees the cookie and
generates a page that uses external files.
The PHP code that handles the dynamic behavior is shown below:
OUTPUT;
}
else {
// If the cookie is NOT present, it's likely the component is NOT cached.
// Inline all the components and trigger a post-onload download of the files.
echo "\n";
echo "\n";
// Output the Post-Onload Download JavaScript code here.
echo <<

