Here is my solution. not passing the google's Eliminate render-blocking JavaScript but you can optimize the first bite time, content download time.
Step1) Script on _Root.Head ( before </body> ) <script type="text/javascript">
function downloadJSAtOnload() { (function (scripts) { var i = 0, l = scripts.length; for (; i < l; ++i) { var element = document.createElement("script"); element.src = scripts[i]; document.body.appendChild(element); } })(['http://www.xxxxxx.com/Themes/NopShop/Scripts/example1.js', 'http://www.xxxxxx.com/Themes/NopShop/Content/example2.js']); }
if (window.addEventListener) window.addEventListener("load", downloadJSAtOnload, false); else if (window.attachEvent) window.attachEvent("onload", downloadJSAtOnload); else window.onload = downloadJSAtOnload;
</script>
Step2) put your .js file source instead of http://www.xxxxxx.com/Themes/NopShop/Scripts/example1.js and example2.js. you can add as many as you want.
Step3) Remove Html.AppendScriptParts and Html.AddScriptParts calls for the scripts you used in step2.
If you test your website on http://www.webpagetest.org/ you will see that your scripts are loading after content download.
ps: make sure you are not defering the scripts need to be loaded before main content, means do not try to over optimize :))
I am making changes for 3.60 I didn't have time either. but I really don't worry abt it bc it only changes 1 or 2 points on google speed. Not a big deal.
but I really don't worry abt it bc it only changes 1 or 2 points on google speed. Not a big deal.
You should. From Abril 21st, Google started to check website's mobile version, so, on mobile, the blocking scripts down score almost 30 points, what results a pretty bad total.
but I really don't worry abt it bc it only changes 1 or 2 points on google speed. Not a big deal.
You should. From Abril 21st, Google started to check website's mobile version, so, on mobile, the blocking scripts down score almost 30 points, what results a pretty bad total.
We must fix it ASAP.
Ivan.
I agree but my mobile speed is 68 now. Passing mobile friendly test. I agree that would be nice to be able to pass that google rule. We are working on gift registry now. That is our priority right now. I think a.m. can give us some ideas about how we can implement remove rendering java script. I saw a work item for inline java scripts. After that it would be easier to find a way.
1- Antes rodei o site e copie todo conteúdo css que foi gerado pelo bundles css para um arquivo chamado master.css que adicionei na pasta principal do site.
2- Em CommonController.cs fiz o seguinte:
//master.css CssHeader [ChildActionOnly] public ActionResult CssHeader() { string result = System.IO.File.ReadAllText(Server.MapPath("~/master.css")); string htmlInput = string.Format("<style type=\"text/css\">{0}</style>", result); return Content(htmlInput); }
2- Em <head> <title>@Html.NopTitle(true)</title> @Html.Action("CssHeader", "Common")
Todo conteúdo css agora é renderizado logo apos o título da página conforme o próprio código fonte da página de testes do Page Speed do Google.
As we said, the big trouble is remove all script from cshtml files. We should test what solution has less impact on response time, once will be a lot of .CS code in .CSHTML files to be processed, than using esxternal .js files.
Another problem on your solution is remove the bundle css file and make it fixed.
But, good job!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.