Reply New Topic
2020/1/7 0:22:35
#1
Offline
Webmaster

Where does the core inject all this javascript?

I'm trying to find out where the core automatically injects javascript in my page. I use Bootstrap theme, and I came to the conclusion that I have 2 jquery scripts, and a load of other scripts as well that are included automatically on my page. Google proposes to change the place on the page, in order to speed the rendering, so I would like to know where the core does that, and perhaps alter the behaviour.


_________________

Me on Ohloh


2020/1/7 9:19:04
#2
Offline
Just can not stay away

Re: Where does the core inject all this javascript?

These comes from <{$icms_module_header}> variable in theme. Sadly, right now I think there is no way to specify place where to output this variable.



2020/1/7 9:51:28
#3
Offline
Home away from home

Re: Where does the core inject all this javascript?

This is the question I had in the slack channel - "async deferred" can be used to move when the javascript is loaded. The actual place is during the renderMetas method of icms_view_theme_Object.

This works for most things and I have it running this way on several sites. The Billboard module does not work properly on the initial page load and renders separate images for each slide until you refresh (works sometimes)


_________________
Christian Web Resources
Facebook

2020/1/7 23:42:32
#4
Offline
Webmaster

Re: Where does the core inject all this javascript?

The billboard module needs major updates and it is no longer used on the site at the moment.

I'll look into the icms_view_theme_Object, because I want to understand where the different javascript and CSS files get included in the core. I believe some of them are not needed on every page. 


_________________

Me on Ohloh


2020/1/8 18:49:25
#5
Offline
Home away from home

Re: Where does the core inject all this javascript?

icms_core_theme_Object does all the work, but the work to be done is defined in /header.php. Just search for ->addScript and ->addStylesheet

include/cp_functions:: icms_cp_header() creates the work for the admin area.

 


_________________
Christian Web Resources
Facebook

2020/1/29 8:10:10
#6
Offline
Webmaster

Re: Where does the core inject all this javascript?

I found the locations in the header file where all the different files were loaded, and I included a switch statement so that I can switch the way includes are done by simply defining a boolean in the theme. When the boolean is true, I include a file 'combined.js' and 'combined.css', which are combined and minified versions of the different javascript and CSS files that are included at the moment. Whent he boolean is false, the old behaviour is still there.

This reduces considerably the loading time (first time at least) of a page. I still have some small issues with the minifying, but I think I have identified the problem.


_________________

Me on Ohloh


2020/1/29 19:08:02
#7
Offline
Home away from home

Re: Where does the core inject all this javascript?

There are minify and combine functions in the core - and currently left unused. Mostly because the resulting file was placed in the cache/ folder and at least one of the js and css files had some specific paths that didn't work when the file was in a different location.


_________________
Christian Web Resources
Facebook

2020/2/10 14:52:31
#8
Offline
Webmaster

Re: Where does the core inject all this javascript?

Those issues are the same ones that I encountered during my tests. After that, I was investigating webpack, and there you can include files with a specific directive, and it tells webpack to make it a relative path.

Perhaps this kind of functionality should be left to the front-end developers and not taken on by the CMS?


_________________

Me on Ohloh


2020/2/10 14:53:08
#9
Offline
Webmaster

Re: Where does the core inject all this javascript?

As a side note, this thread does not show paragraph tags when I post something new. Strange


_________________

Me on Ohloh


2020/2/16 14:01:34
#10
Offline
Home away from home

Re: Where does the core inject all this javascript?

From a new post in an old topic - https://www.impresscms.org/modules/iforum/viewtopic.php?post_id=50656#forumpost50656

Wondering about the options below


_________________
Christian Web Resources
Facebook

Reply New Topic extras
 Previous Topic   Next Topic
You can view topic.
You can start a new topic.
You can reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You can post without approval.