Remove Render-Blocking JavaScripts

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
8 年 前
Hi guys!

So, here is what we fixed in code:


if (content.Contains("</body>"))
                {
                    StringBuilder inline = new StringBuilder();
                    StringBuilder js = new StringBuilder();
                    StringBuilder css = new StringBuilder();

                    //inlinescript with tag <script type="text/javascript">
                    bool inlineScriptExist = content.Contains("<script type=");

                    while (inlineScriptExist)
                    {
                        int startTag = content.IndexOf(@"<script type=");
                        int endTag = content.IndexOf(@"</script>", startTag);
                        string script = content.Substring(startTag, endTag - startTag + 9);

                        string toReplace = content.Substring(startTag, content.IndexOf(">", startTag) + 1);

                        string inlinescript = script.Replace(toReplace, "").Replace("</script>", "");
                        inline.Append(inlinescript);
                        content = content.Replace(script, "");
                        inlineScriptExist = content.Contains("<script type=");
                    }

                    //inlinescript with tag <script>
                    inlineScriptExist = content.Contains("<script>");

                    while (inlineScriptExist)
                    {
                        int startTag = content.IndexOf(@"<script>");
                        int endTag = content.IndexOf(@"</script>", startTag);
                        string script = content.Substring(startTag, endTag - startTag + 9);
                        string inlinescript = script.Replace("<script>", "").Replace("</script>", "");
                        inline.Append(inlinescript);
                        content = content.Replace(script, "");
                        inlineScriptExist = content.Contains("<script>");
                    }

                    inlineScriptExist = content.Contains("<script src=");

                    //put js script src to bottom
                    while (inlineScriptExist)
                    {
                        int startTag = content.IndexOf(@"<script src=");
                        int endTag = content.IndexOf(@"</script>", startTag);
                        string script = content.Substring(startTag, endTag - startTag + 9);

                        js.Append(script);
                        content = content.Replace(script, "");
                        inlineScriptExist = content.Contains("<script src=");
                    }


Then, we finished a new plugin that will help a lot to get better results on Google PageSpeed Insights, you can get it here: https://www.nopcommerce.com/p/2046/pagespeed-insights.aspx
8 年 前
Hi, I sent a pm to you.
8 年 前
Hi,

I tried to place the css file to the bottom of the page. Unfortunatelly I have with is kind of solution still the rendering blocking script issue (See testshop.equi-vision.de). I disable minize HTML for a better overview. I see no difference to your demo store. Do you know what the difference is?

Regards,

Dominik
8 年 前
Ivan, are you offering free upgrade for 3.70 when it releases?
8 年 前
If I test your site your plugin works at the moment only on the home page. On all other pages the rendering blocking script issue is still there.  See google insights

I think it is nessesary to put the css in line. But than you have problems If you have large css files. If I have any Idea for this issue I will post it.
8 年 前
About your plugin. What about adding support for version 3.5? We are not going to do a migration just because of the plugin (since we have customized the current version a lot), but we are willing to pay for increasing PageSpeed results. And what about bug fixes. Does it still only work on the home page?
8 年 前
evgeniygerasimov wrote:
About your plugin. What about adding support for version 3.5? We are not going to do a migration just because of the plugin (since we have customized the current version a lot), but we are willing to pay for increasing PageSpeed results. And what about bug fixes. Does it still only work on the home page?


Hi. It works on entire site. There 1.03 version will be release today with a lot of improvements. I'll include 3.5 support.

I let you know.
8 年 前
Hi there!

The 1.03 version is available and have a lot of improvements.

Now, compatible with NopCommerce 3.5

You can find it here: http://www.nop-store.com/en/pagespeed-insights

Thanks!
8 年 前
Hi there.

I bought the plugin. It is nice, thanks. But it does not yet function properly. I got couple of problems with it. The main one is that it removed render-blocking CSS for mobile, but stile no luck with desktop. I use the responsive theme, but that should not probably matter.

Can you have a look. I think you just have not covered all the possible cases. And here you go.

Run the test on http://galeria.com.ua and go to desktop tab.

Thank you.
8 年 前
And one more thing. I need to mention that image optimization feature will not work on shared hosting environment since you are not allowed to run exe files.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.