WordPress.org

Ready to get started?Download WordPress

Forums

WordPress Related Posts
[resolved] Injecting scripts and styles (2 posts)

  1. jp2112
    Member
    Posted 1 year ago #

    I like this plugin. What I'm not thrilled with is that the wp_rp_head_resources function has a mix of injection and enqueuing. It is injecting javascript into the header with no way of stopping it since it isn't being enqueued.

    Also, even though there is a CSS file (loaded from Cloudfront, which I fail to understand), there is still some CSS being inlined anyway. Can someone please explain the rationale for this behavior? Why not just create another CSS file?

    Finally, the scripts and styles are loaded on every page. May I suggest you find a way to make it conditional?

    Again, great plugin, but I'll need to create some workarounds for these behaviors.

    http://wordpress.org/extend/plugins/wordpress-23-related-posts-plugin/

  2. silvoslaf
    Member
    Plugin Author

    Posted 1 year ago #

    Hey!

    Thanks for reaching out! We're more than glad to explain our ways of work.

    The issue with JavaScript is actually in the design of WordPress. WordPress only supports enqueuing files into the <head> portion of the site before the content of the article is printed. So, due to the fact that we support dynamic inclusion of related posts (i.e. authors can include related posts with a special tag in the article text), and since we want to include JavaScript files in the <head> to speed up user experience, we realized that we must -unfortunately- include JavaScript (and CSS) files in every page.

    CSS files are loaded from CloudFront to improve caching and speed up loading of websites. In newer versions, we added the option to include custom CSS as well, and our existing plugin infrastructure made it easier to load CSS from the database and inline it into the HTML than to include it to a separate file.

    Hope this helps a bit. But do let me know if you have any further questions or if something is not completely clear — we are hear to help!

    Take care & have a nice day!

    Best,
    Silvo

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic