Link css file on content page

Is possible to link a css and js file on content page?? Or I need to put on the layout page head??

The css is only usable on specific content page but layout is used on multiple pages.

Hi Chackmool

Always load it into layout page.
The js file bzw. The functions of the js files can be loaded by a page load flow.

But how do you avoid to load a lot of css that is no used on all the pages ? Only in one page from all pages in that template?

You can load the CSS from the content page, but I think that you will have to do this in code view. I do not think that Wappler has a way to do that.

Having said that, why not attach the style rules to the main style sheet? Bootstrap already has many style rules that are not used in all of the pages, e.g. <button>.

Hi Ben, thank you. I always strive to load only the necessary files to prevent overloading. Sometimes, I include a slider on a specific page that is not used in other parts of the site. Perhaps I have an obsession with loading only the necessary files.

For regular CSS and JS files, its fine to add manually to content page like Ben has confirmed.
Also, as he has suggested, it the styles are just some custom classes, better alternative is to add them to theme manager.

Talkong about external libraries, is definitely a good practice to not add the files to layout page… But to add on content pages where they are used.

Lastly, if you are talking about Wappler slider specifically, you have no option but to add it to layout page. There is no way to add Wapper component’s js/css file on content page only - from what I know.

1 Like