Hammad Hassan Hammad Hassan - 2 years ago 131
PHP Question

How to Load Resources (Css, js files) in Laravel 4 (Optimization)

I searched for the similar question on stack over flow, but unable to find any.

I know how to load css and js files in laravel 4, but when we load these files using asset() method or throught HTML-Builder HTML::script($url, $attributes); everyone will have notice that it loads files something like that http:// something/public/themeName/style.css

I wonder, is there any way to load files, like we used to be css/style.css

Actually, i would like to reduce the number of HTTP requests done when loading a page.

I know (css/style.css) will also fire an HTTP request but didn't it will took less time to load resources than "http:// something/public/themeName/css/style.css" ?


Sorry forget to mention, actually this method works fine "css/style.css" when we use it for only one page in laravel. But when we need to reload same files on diff pages in laravel, we use asset() and HTML Builders for that. which then loads these resources like "http:// appname/public/js/javascript.js"

But i would like to load it like we normally do (js/javascript.js).

Answer Source

"href="css/style.css" will fire an HTTP request nonetheless, it's just a relative path instead of an absolute."

Thank you @Damien Pirsy you are right, answering it myself so if someone looking to the similar issue might not get confused.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download