Thursday, August 15, 2013

How to make sure that a CSS file will load on your site using PHP

This is a simple trick. Most of the web developers worry that the Stylesheet file will not load completely. This happens if your CSS file's size is too large. The fail in complete loading of the file mostly happens to users who are using slower connections like me.

The page will look disgusting if the CSS file don't load. To avoid the file not getting loaded you can do this simple trick using PHP.

Open your PHP page and replace the lines that embed the stylesheet file.

Replace this:

<link href="" rel="stylesheet" />  
With this:

<style><?echo file_get_contents('');?></style>
When the page loads the CSS styles of the external file will be loaded in the <style> tag. This method won't fail. PHP make sure that the CSS file loads.

No comments:

Post a Comment