[BUG] Script and Styles are Loaded on Non Anspress Pages.

4.42K viewsIssues
1

The Anspress scripts and styles should not be loaded on every page but only on the anspress pages that need them.

You should wp_register_script/style during enqueue_script hook but only enqueue them with wp_enqueue_script on pages where anspress is actually loaded.

I saw a actual commented out //if( is_anspress() in the script enqueue function. But commenting it in did not work. Now I see you removed it on latest Git. Why? You should really have a solution for this.

0

I tried using Gonzales to do the same thing, but frankly its a pain in the ass to have to do manually, and ought to be built-in.

Who, but the author, knows and can easily keep track of which pages need to load which scripts and need which CSS support.

Then I can go back to using Gonzales for dealing with other less careful authors.

Your Answer should be a comment not a answer, which brings up a question if its possible with Anspress to convert a answer to comment. Q2A can do that.

I am currently using quesiton2answer but I am considering switching to anspress because its tightly integrated with wordpress and uses it as a platform. q2a can use the WP user database but thats it.

Q2A does not have a feature to make a question private. So I love that Anspress ha

It looks like it was planned but then abandoned, thats a shame. Scripts and styles should not pollute every singe wordpress page.

When you have a shortcode you can simply enqueue the scripts and styles mid page when the shortcode is executed. I do so in my plugins. I not know the structure of anspress is and if the scripts needed to be included in the head, I tried hooking the functions to a later hook ‘enqueue_scripts’ because I guessed the detection if anspress is active only works at a later hook. But then Anspress stopped to work properly.

I am currently to busy to figure this out myself, also I am not the author so its very hard for me, I had to learn all the code.

That’s funny. I was just thinking the same thing.