不执行preLOAD脚本 [英] Preload script without execute

查看:129
本文介绍了不执行preLOAD脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了提高性能页的我需要preLOAD脚本,我需要的底页上运行即可。

In order to improve the page performance I need to preload scripts that I will need to run on the bottom page.

我想借此当脚本解析,编译和执行的控制。

I would like to take control of when the script is parsed, compiled and executed.

我必须避免script标签,因为它是阻滞剂,共同渲染引擎(geeko,等等)。

I must avoid the script tag, because it is blocker for common render engines (geeko, etc).

我无法通过的延迟属性,因为我需要的是执行脚本时要控制加载它。
此外,异步属性的可能性也不大。

I can't load it using defer property, because I need to control when the script is executed. Also, async property is not a possibility.

示例:

<html><head>
//preload scripts ie: a.js  without use the script
</head><body> ..... all my nice html here
//execute here a.js
</body></html>

这让我最大限度地使我的网页的性能,因为浏览器将开始donwload脚本的内容,将在并行的同时渲染页面。最后,我可以添加脚本标记,因此浏览器将解析,编译和执行code。

This allows me to maximize the render performance of my page, because the browser will start to donwload the scripts content, and it will render the page at the same time in parallel. Finally, I can add the script tag, so the browser will parse, compile and execute the code.

这是我能做到这一点的唯一方法是使用隐藏的图像标记。 (这是斯托扬的简化版本)

The only way that I could do that is using a hidden image tag. (This is a simplified version of Stoyan)

 <html><head>
 <img src="a.js" style=display:none;>
</head><body> ..... all my nice html here
 <script src="a.js">  
</body></html>

问题

我没有发现使用这种技术的任何问题,但没有人知道一个更好的方式来做到这一点?
是否有任何元prefetch?

Question

I didn't find any problem using this technique, but does anyone know a better way to do this? Is there any meta prefetch?

我使用的 requirejs ,所以我试图preLOAD模块code,而不执行它,因为这$ C $,c取决于DOM元素。

I'm using requirejs, so I'm trying to preload the modules code, without executing it, because this code depends of DOM elements.

推荐答案

您应该看看下面的链接:

You should have a look at the following links:

http://calendar.perfplanet.com/2011/lazy - 评价 - 的 - CommonJS的模块/

http://tomdale.net/2012/01/amd -is而不是最接听/

和快速。

这篇关于不执行preLOAD脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆