I started working on a project a came across a strange way to include a CSS file using javascript.
Example from the project:
document.write('<link rel="stylesheet" type="text/css" href="css/plugins/jquery.datatables.css" />');
Is there any reason (advantage) to include the file this way?
The CSS file will only be added to the page if the user has JavaScript enabled. Bandwidth saver.
This code does not include JavaScript but the CSS include...by using JavaScript. It allows to dynamically select your CSS maybe to select themes or adapt layout to the device.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With