I have a website built with PHP and I want to implement something similar to ASP's masterpages. So I built something like this:
<!DOCTYPE hmtl>
<html>
<head>
//Generated from PHP (meta,css,javascript,title)
//Can be modified in the controller before page display
</head>
<body>
//Include the page content
//Includes page specific javascript
<?php include $page ?>
</body>
</html>
My problem is that this clutters the controller and makes SEO Analyzers very unhappy. So here is a list of problems I am facing and would like to know how to resolve.
- Is there any other way to include page/plugin specific css to the header tag without having a bunch of $config->addCSS(//Tag goes here//) in my controller?
- Google says to remove jQuery and Bootstrap scripts from the header, but I have page specific scripts (handlebars) that require jQuery. How can I move jQuery to the bottom of the body tag, but before my page scripts which are included in $page?
Possible solutions that I don't really like:
- Use javascript to include the page specific css within the $page variable. That's possible, but won't I get a FOUT("Flash of Unstyled Text")?
2.1 Inlcude jQuery/Bootstrap at the bottom of the $page variable. That's nice until a new version comes out and all the pages have to be updated.
2.2 For every single page, have another page that contains the scripts and the include that in the masterpage afer I have included required scripts (jQuery/Boostrap).
Aucun commentaire:
Enregistrer un commentaire