WO2014090187A1 - 在浏览器中处理页面的方法及设备 - Google Patents

在浏览器中处理页面的方法及设备 Download PDF

Info

Publication number
WO2014090187A1
WO2014090187A1 PCT/CN2013/089352 CN2013089352W WO2014090187A1 WO 2014090187 A1 WO2014090187 A1 WO 2014090187A1 CN 2013089352 W CN2013089352 W CN 2013089352W WO 2014090187 A1 WO2014090187 A1 WO 2014090187A1
Authority
WO
WIPO (PCT)
Prior art keywords
browser
registered
rendered
elements
page
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Ceased
Application number
PCT/CN2013/089352
Other languages
English (en)
French (fr)
Inventor
韩学斌
黄欢
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Qihoo Technology Co Ltd
Qizhi Software Beijing Co Ltd
Original Assignee
Beijing Qihoo Technology Co Ltd
Qizhi Software Beijing Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Qihoo Technology Co Ltd, Qizhi Software Beijing Co Ltd filed Critical Beijing Qihoo Technology Co Ltd
Publication of WO2014090187A1 publication Critical patent/WO2014090187A1/zh
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/957Browsing optimisation, e.g. caching or content distillation

Definitions

  • the present invention relates to the field of computer technologies, and in particular, to a method and device for processing a page in a browser. Background technique
  • Delayed rendering means that the part that has not been browsed by the user is not parsed and rendered in the webpage, and the content of the part is loaded, parsed and rendered and displayed when the user browses down to the corresponding location. For example, when some users only browse content within a certain range of a web page, other content within the web page does not need to be loaded. In this way, the speed of web page display can be effectively accelerated, and the consumption of the server can be reduced.
  • the present invention has been made in order to provide a method and apparatus method for processing a page in a browser that overcomes the above problems or at least partially solves the above problems.
  • a method for processing a page in a browser comprising the steps of: registering an element in the page that requires a delayed presentation; parsing and rendering an unregistered element in the page in a browser; Determine whether to parse and render the registered element, parse and render the registered element in the browser if parsing and rendering, otherwise store the registered element; and render the rendered current window in the browser Elements.
  • an apparatus for processing a page in a browser comprising: an element registrar configured to register an element in a page that requires a delayed presentation; an element parser and a renderer configured to Parsing and rendering unregistered elements in the page in the browser; element parsing and rendering determiner, configured to determine whether to parse and render the registered element, if parsed and rendered, by element parsing and renderer The registered element is parsed and rendered in the browser; the element register is configured to store the registered elements that the element parsing and rendering determiner determine not to parse and render; and the element renderer is configured to render by the element parsing and The element that is parsed and rendered by the renderer and located in the current window of the browser.
  • the elements that need to be delayed are rendered in a delayed manner, so that the registered elements in the page are subjected to delayed rendering processing, so that not only the images in the page can be subjected to delayed rendering processing, but also other page elements can be performed. Delayed rendering processing, thereby effectively increasing the display speed of the page.
  • FIG. 1 shows a flow diagram of a method of processing a page in a browser, in accordance with one embodiment of the present invention
  • FIG. 2 shows a block diagram of an apparatus for processing a page in a browser in accordance with one embodiment of the present invention
  • FIG. 3 shows a block diagram of an intelligent electronic device for performing the method according to the present invention
  • FIG. 4 shows A schematic diagram of a memory unit that holds or carries program code that implements the method in accordance with the present invention.
  • Web pages run in a variety of browsers, and the speed at which browsers load, parse, and render pages directly impacts the user experience.
  • the present invention proposes a method of processing a page in a browser and a device for processing a page in a browser.
  • the method for processing a page in a browser proposed by the present invention mainly comprises: registering an element that needs to be delayed, and then performing delayed analysis, rendering and rendering on the registered element that needs to be delayed, so as to make the page
  • the registered elements in the delay rendering process can not only delay the rendering of the images in the page, but also delay the rendering of other page elements, thereby improving the page display speed.
  • a flowchart of a method 100 for processing a web page in a browser suitable for solving the above technical problems according to an embodiment of the present invention is specifically described below with reference to FIG.
  • the register of the element elements in the page page surface that needs to be delayed is required to be registered.
  • the element element that needs to be extended when the delay is required may be a text word, a picture image ((still static image image and dynamic dynamic image image) Any of the following:)), FF llaasshh animation, sound sound, video frequency, table grid, navigation navigation bar, and interactive interactive form sheet One species. .
  • the cocoa is embedded into the self-defined definition class type by embedding the meta-element that is present when the delay is required.
  • the ssccrr iipptt label in the type of the implementation of the current registration register needs to be extended to present the current element, the code of which is as follows:
  • HHTTM MLL code code that is present when the delay is to be presented.
  • step S120 the unregistered elements in the page are parsed and rendered in the browser.
  • unregistered elements can be any of text, images (still images and moving images), Flash animations, sounds, videos, tables, navigation bars, and interactive forms.
  • the page rendering engine can be used to parse and render unregistered elements of the page, and the page rendering engine is responsible for processing the content of the web page (HTML, XML, images, etc.), organizing information (eg, adding CSS, etc.), parsing out the webpage. The relationship between the various elements in the calculation, and the results of the calculation and preparation of the final page to be displayed on the display.
  • the page rendering engine can be the Tr ident typesetting engine (the name of the web browser of Microsoft's Windows operating system (Windows), the name of the Internet Explorer's typesetting engine), or the Gecko typesetting engine (a set of open source, in C++). Written by the web page layout engine). It will of course be understood that the specific type of page rendering engine is not limited in embodiments of the invention.
  • step S130 it is judged whether or not the registered element is to be parsed and rendered.
  • Method 1 Determine whether the registered element is located in the current window of the browser, which can be analyzed according to the page rendering engine. Whether the non-registered element around the registered element is displayed in the current window of the browser to determine; Method 2, determine whether the page scrolls in the browser window.
  • the element in the current window of the browser refers to the element in the page that is displayed in the current window.
  • a page is formed by an HTML document.
  • the overall height of an HTML document is higher than the height of the browser window. Then some of the pages are hidden. You can view the hidden pages by moving the scroll bar of the browser. .
  • the unregistered elements of the page are parsed and rendered in the browser, and after parsing and rendering are completed, it is determined whether the registered element needs to be parsed and rendered, if the element needs to be rendered immediately (the registered element is located in the browser) The current window or scroll down the page), then proceeds to step S140, Step S140, parsing and rendering the registered element in the browser; otherwise, proceeding to step S150, storing the registered element in step S150, waiting for a suitable timing (for example, when the content presented on the current window of the browser changes) Present again.
  • the implementation code for this section is as follows:
  • step S130 it is determined that parsing and rendering are required, and the process proceeds to step S140.
  • step S140 After the registered element is parsed and rendered in the browser in step S140, the process proceeds to step S160, where the parsed and rendered are presented. An element located in the browser's current window, and then ends the entire method flow 100.
  • step S130 when it is determined in step S130 that parsing and rendering are not required, the process proceeds to step S150, and after step S150, the process returns to step S130, so that when the content presented on the current window of the browser changes, It is also possible in step S130 to determine whether a registered element that was previously stored without being parsed and rendered is to be presented.
  • step S120 may also be after step S160, or Simultaneously with step S160, the steps are not limited to the above-mentioned step division, and the above steps may be further divided into more steps or may be combined into fewer steps.
  • the apparatus 200 for processing a page in a browser of the present invention includes: an element registrar
  • Element parsing and rendering determinator 220 element parsing and renderer 230, element renderer 240, and element register 260.
  • the element registrar 210 is configured to register elements of the page that need to be rendered in a delayed manner.
  • the elements that need to be rendered in a delayed manner can be any of text, images (still images and moving images), Flash animations, sounds, videos, tables, navigation bars, and interactive forms.
  • element registrar 210 embeds elements that require deferred rendering into a custom type of scr ipt tag for registration.
  • the code is as follows:
  • the element parsing and renderer 230 is configured to parse and render unregistered elements in the page and elements registered in the element registrar 210 that need to be parsed and rendered in the browser.
  • unregistered elements can be any of text, images (still images and moving images), Flash animations, sounds, videos, tables, navigation bars, and interactive forms.
  • the element parsing and rendering unit 230 is responsible for obtaining the content of the web page (HTML, XML, images, etc.), organizing the information (for example, adding CSS, etc.), and calculating the display manner of the web page, and then outputting to the display screen of the electronic device, element analysis and
  • the renderer 230 can be a Tr ident typesetting engine (a web browser of Microsoft's Windows operating system (Windows) - the name of the Internet Explorer's typesetting engine), or a Gecko typesetting engine (a set of open source, Web page layout engine written in C++). It will of course be understood that the specific types of element parsing and renderer 230 are not limited in embodiments of the invention.
  • the element parsing and rendering determiner 220 is configured to determine whether the registered element is to be parsed and rendered, and if it is to be parsed and rendered, the element parsing and rendering 230 parses and renders the registered element in the browser.
  • the registered elements can be any of text, images (still images and moving images), Flash animations, sounds, videos, tables, navigation bars, and interactive forms.
  • the unregistered elements of the page are parsed and rendered by the element parsing and rendering unit 230 in the browser.
  • the element parsing and rendering determiner 220 determines whether the registered elements need to be parsed and Rendering, if the registered element needs to be rendered immediately (either in the browser's current window or scrolling down the page), the element parsing and rendering 230 will parse and render the registered element that needs to be parsed and rendered, and then render by the element.
  • the element parsing and rendering determiner 220 determines whether the registered element is to be parsed and rendered by determining if the registered element is in the current window of the browser. In other embodiments, the element parsing and rendering determiner 220 also determines whether the registered element is to be parsed and rendered by determining whether the page scrolls through the browser's window.
  • Element renderer 240 is configured to present elements in the current window of the browser that are parsed and rendered by element parsing and renderer 230.
  • the stored elements are handed over to the element renderer 240 for rendering, and the partial implementation code is as follows:
  • Element register 260 is configured to store registered elements that element resolution and rendering determiner 220 determine to not parse and render.
  • the element solution when the content presented on the browser's current window changes, the element solution
  • the parsing and rendering determiner 220 determines whether the registered elements stored by the element register 260 are to be parsed and rendered, and if parsed and rendered, parsed and rendered by the element parsing and renderer 230 is stored by the element register 260. The registered element.
  • modules in the devices of the embodiments can be adaptively changed and placed in one or more devices different from the embodiment.
  • the modules or units or components of the embodiments may be combined into one module or unit or component, and further they may be divided into a plurality of sub-modules or sub-units or sub-components.
  • any combination of the features disclosed in the specification, including the accompanying claims, the abstract and the drawings, and any methods so disclosed, or All processes or units of the device are combined.
  • Each feature disclosed in the specification (including the accompanying claims, the abstract and the drawings) may be replaced by alternative features that provide the same, equivalent or similar purpose, unless otherwise stated.
  • the various component embodiments of the present invention may be implemented in hardware, or in a software module running on one or more processors, or in a combination thereof.
  • Those skilled in the art will understand that Some or all of the functionality of some or all of the means for processing a page in a browser in accordance with an embodiment of the present invention may be implemented in practice using a microprocessor or digital signal processor (DSP).
  • DSP digital signal processor
  • the invention can also be implemented as a device or device program (e.g., a computer program and a computer program product) for performing some or all of the methods described herein.
  • Such a program implementing the invention may be stored on a computer readable medium or may be in the form of one or more signals. Such signals may be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.
  • the electronic device conventionally includes a processor 310 and a computer program product or computer readable medium in the form of a memory device 320.
  • the memory 320 may be a storage space 330 of a code 331 such as a flash memory, an EEPROM (Electrically Erasable Programmable Read Only Memory), an EPROM, a hard disk, or a ROM.
  • the storage space ⁇ 30 for the program code may include reading or writing to the one or more program products in one or more computer program products, respectively.
  • These computer program products include program code carriers such as hard disks, compact disks (CDs), memory cards or floppy disks. Such a computer program product is typically a portable or fixed storage unit as described with reference to FIG.
  • the storage unit may have a storage section or a storage space or the like arranged similarly to the storage 320 in the intelligent electronic device of FIG.
  • the program code may, for example, be in a proper order, ie, code readable by a processor, such as 310, which, when executed by the intelligent electronic device, causes the intelligent electronic device to perform the method described above Each step.

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

本发明公开了一种在浏览器中处理页面的方法及设备,该方法包括:对页面中需要延时呈现的元素进行注册;在浏览器中解析并渲染该页面中未注册的元素;判断是否要解析并渲染所注册的元素,如果要解析并渲染,则在浏览器中解析并渲染所注册的元素,否则存储所注册的元素;以及呈现所渲染的、位于浏览器的当前窗口中的元素。通过对需要延时呈现的元素进行注册,然后对所注册的需要延时呈现的元素进行延时解析、渲染和呈现,从而不仅能对页面中的图片进行延时呈现处理,而且能对其它的页面元素进行延时呈现处理,由此有效提高了页面的显示速度。

Description

在浏览器中处理页面的方法及设备 技术领域
本发明涉及计算机技术领域,具体涉及一种在浏览器中处理页面的方法及 设备。 背景技术
随着互联网的发展, 网站提供的内容越来越丰富,吸引了越来越多的用户 浏览。 然而, 网站大量内容的展示同时也拖慢了网页的显示速度, 于是延时呈 现技术应运而生。延时呈现,是指在网页中先不解析和渲染还没有被用户浏览 到的部分, 而等到用户向下浏览至相应位置时才加载、解析和渲染并显示该部 分的内容。 例如, 当有些用户只浏览网页中某一范围内的内容时, 网页中的其 它范围内的内容就不需要加载了。 这样, 可以有效地加快网页显示速度, 还可 以降低服务器的消耗。
然而在现有技术中, 只能对页面中的图片进行延时呈现处理,对其它的页 面元素则无法进行延时呈现。 发明内容
鉴于上述问题,提出了本发明以便提供一种克服上述问题或者至少部分地 解决上述问题的在浏览器中处理页面的方法及设备方法。
依据本发明的一个方面,提供了一种在浏览器中处理页面的方法, 包括步 骤: 对页面中需要延时呈现的元素进行注册; 在浏览器中解析和渲染该页面中 未注册的元素; 判断是否要解析和渲染所注册的元素, 如果要解析和渲染, 则 在浏览器中解析和渲染所注册的元素, 否则存储所注册的元素; 以及呈现所渲 染的、 位于浏览器的当前窗口中的元素。
根据本发明的另一个方面, 提供一种在浏览器中处理页面的设备, 包括: 元素注册器,被配置为对页面中需要延时呈现的元素进行注册; 元素解析和渲 染器,被配置为在浏览器中解析和渲染该页面中未注册的元素; 元素解析和渲 染判定器,被配置为判断是否要解析和渲染所注册的元素,如果要解析和渲染, 则由元素解析和渲染器在浏览器中解析和渲染所注册的元素; 元素暂存器,被 配置为存储元素解析和渲染判定器判断为不解析和渲染的已注册元素;以及元 素呈现器,被配置为呈现由元素解析和渲染器所解析和渲染的、位于浏览器的 当前窗口中的元素。 的需要延时呈现的元素进行延时呈现,以使得对页面中的注册过的元素进行延 时呈现处理,从而不仅能对页面中的图片进行延时呈现处理, 而且能对其它的 页面元素进行延时呈现处理, 由此有效提高了页面的显示速度。
上述说明仅是本发明技术方案的概述,为了能够更清楚了解本发明的技术 手段,而可依照说明书的内容予以实施,并且为了让本发明的上述和其它目的、 特征和优点能够更明显易懂, 以下特举本发明的具体实施方式。 附图说明
通过阅读下文优选实施方式的详细描述,各种其他的优点和益处对于本领 域普通技术人员将变得清楚明了。 附图仅用于示出优选实施方式的目的, 而并 不认为是对本发明的限制。 而且在整个附图中, 用相同的参考符号表示相同的 部件。 在附图中:
图 1示出了根据本发明一个实施例的在浏览器中处理页面的方法的流程 图; 以及
图 2示出了根据本发明一个实施例的在浏览器中处理页面的设备的框图; 图 3示出了用于执行根据本发明的方法的智能电子设备的框图; 以及 图 4示出了用于保持或者携带实现根据本发明的方法的程序代码的存储单 元示意图。 具体实施方式
下面将参照附图更详细地描述本公开的示例性实施例。虽然附图中显示了 本公开的示例性实施例, 然而应当理解, 可以以各种形式实现本公开而不应被 这里阐述的实施例所限制。相反,提供这些实施例是为了能够更透彻地理解本 公开, 并且能够将本公开的范围完整的传达给本领域的技术人员。
Web页面运行在各种各样的浏览器当中, 浏览器载入、 解析和渲染页面的 速度直接影响着用户体验。本发明提出一种在浏览器中处理页面的方法和一种 在浏览器中处理页面的设备。 本发明提出的在浏览器中处理页面的方法主要 是,通过对需要延时呈现的元素进行注册, 然后对所注册的需要延时呈现的元 素进行延时解析、渲染和呈现, 以使得对页面中的注册过的元素进行延时呈现 处理, 不仅能对页面中的图片进行延时呈现处理, 而且能对其它的页面元素进 行延时呈现处理, 从而提高页面显示速度。 下面结合图 1具体说明根据本发明 一个实施例的、 适于解决上述技术问题的在浏览器中处理网页的方法 100的流 程图。 骤骤 SS111100中中,, 对对页页面面中中需需要要延延时时呈呈现现的的元元素素进进行行注注册册。。 可可选选地地,, 需需要要延延时时呈呈现现的的 元元素素可可以以是是文文字字、、 图图像像((静静态态图图像像和和动动态态图图像像)) 、、 FF llaasshh动动画画、、 声声音音、、 视视频频、、 表表格格、、 导导航航栏栏和和交交互互式式表表单单中中的的任任意意一一种种。。
可可选选地地,,在在步步骤骤 SS111100中中,, 可可通通过过将将需需要要延延时时呈呈现现的的元元素素嵌嵌入入到到自自定定义义类类型型 的的 ssccrr iipptt标标签签中中的的方方式式实实现现注注册册需需要要延延时时呈呈现现的的元元素素,, 其其代代码码如如下下::
< <ssccrr iipptt ttyyppee=="" llaazzyyllooaadd "" >>
这这里里是是要要延延时时呈呈现现的的 HHTTMMLL代代码码
< <// ssccrr iipptt>>
通通过过注注册册可可以以将将部部分分 HHTTMMLL代代码码变变成成某某种种注注释释,,而而不不让让浏浏览览器器将将这这些些代代码码解解
Figure imgf000005_0001
随后, 在步骤 S120中, 在浏览器中解析和渲染该页面中未注册的元素。 其
Figure imgf000005_0002
要显示在浏览器窗口中的网页内容的过程。
可选地, 未注册的元素可以是文字、 图像(静态图像和动态图像)、 Flash 动画、 声音、 视频、 表格、 导航栏和交互式表单中的任意一种。 可选地, 可通 过页面渲染引擎来解析和渲染该页面中未注册的元素,页面渲染引擎负责处理 网页的内容(HTML、 XML , 图像等) 、 整理信息(例如加入 CSS等) , 解析出网 页中各个元素之间的关系,以及计算和准备好网页最后要在显示器上显示的结 果。页面渲染引擎可以是 Tr ident排版引擎(是微软的视窗操作系统(Windows ) 搭载的网页浏览器一 Internet Explorer的排版引擎的名称) , 也可以是 Gecko 排版引擎(是套开放源代码的、 以 C++编写的网页排版引擎) 。 当然可以理解 的是, 在本发明的实施例中并不限定页面渲染引擎的具体类型。
随后, 在步骤 S130中, 判断是否要解析和渲染所注册的元素。 可选地, 可 通过以下两种方式判定是否要解析和渲染所注册的元素: 方式一、判断所注册 的元素是否位于浏览器的当前窗口中, 这可以根据在页面渲染引擎所分析的、 在所注册元素周围的非注册元素是否显示在浏览器的当前窗口中来进行判断; 方式二、 判断页面是否在浏览器的窗口中滚动。
其中,位于浏览器的当前窗口中的元素是指页面中在浏览当前窗口中显示 的元素。通常一个页面由一个 HTML文档形成, 一个 HTML文档的整体高度高于浏 览器窗口的高度, 那么一部分的页面会处于隐藏的状态, 可以通过移动浏览器 的滚动条来达到查看处于隐藏状态的部分页面。
在一些实施例中,在浏览器中解析和渲染该页面中未注册的元素,解析和 渲染完成后, 判断是否需要解析和渲染所注册的元素,如果元素需要立即呈现 (注册的元素位于浏览器的当前窗口或向下滚动页面), 则进入步骤 S140 , 在 步骤 S140, 在浏览器中解析和渲染所注册的元素; 否则, 进入步骤 S150, 在步 骤 S150, 存储所注册的元素, 等待合适时机(例如当浏览器的当前窗口上呈现 的内容发生变化时)再进行呈现。 该部分的实现代码如下:
//遍历所有注册的元素
$ (/ script [type=lazyload] / ) . each (function () {
var $this = $ (this) ;
//不是浏览器的当前窗口或用户滚动到的元素
if ($this. offset (). top - $ (window) . scroll Top () > documen t. document Element, cl ientHeight) {
//存储不需立即呈现的元素
lazy, push ($this);
} else {
//否则, 立即呈现
replace ($this);
}
});
在步骤 S130中判断需要解析和渲染而进入到步骤 S140,在步骤 S140中对所 注册的元素在浏览器中进行解析和渲染之后, 进入步骤 S160, 在步骤 S160中, 呈现所解析和渲染的、位于浏览器的当前窗口中的元素, 然后结束整个方法流 程 100。
可选地, 当需要呈现元素时(即注册的元素位于浏览器的当前窗口或向下 滚动页面时) , 则对注册的元素进行呈现, 步骤 S160的部分实现代码如下: var replace = function(ele){
ele = typeofele == 'object'? ele: this;
ele. replaceWith( ele.val()\\ ele.html( ) );
};
另外, 在步骤 S130中判断不需要解析和渲染时, 则进入到步骤 S150, 而在 步骤 S150之后, 还返回到步骤 S130中, 这样, 在浏览器的当前窗口上呈现的内 容发生变化时,在步骤 S 130中还可以判断是否要呈现之前未被解析和渲染而被 存储的所注册的元素。
需要说明的是, 图 1所示的方法并不限定按所示的各步骤的顺序进行, 可 以根据需要调整各步骤的先后顺序, 例如步骤 S120也可在步骤 S160之后, 或者 与步骤 S 160同时进行, 另外, 所述步骤也不限定于上述步骤划分, 上述步骤可 以进一步拆分成更多步骤也可以合并成更少步骤。
下面结合一个具体的示例,来介绍本发明的实施例中的在浏览器中处理页 面的方法的流程, 实现代码如下:
〈! DOCTYPE HTML>
<html>
<hcad>
<mc ta ht tp-cqui v= "Con ten t-Type " con ten t= "tcxt/h tml; charset=utf-8" />
<ti tle> zyU d示例 </ti tle>
</head>
<body>
<div>
这里是浏览器当前窗口的内容
. . .
</div>
〈!一注册延时呈现的元素一〉
< script type= "lazyloa d ">
这里是需要延时呈现的内容
</script>
< script
src="ht tp: //s0. qhimg. com/ lib/ jquery/172. js "></script>
<script>
var lazy load = function () {
var lazy = [], //对注册的元素进行存储
〃对元素进行呈现
replace = function (clc) { ele = typeof ele == object ? ele : this;
ele. replaceWi th (ele. val () I lele. h tml ()) ;
};
return {
in i t: fun ction () {
//判定元素是否被渲染
$ scri t [ type=lazyloa d] / )■ each (f unc t ion () { //遍 历所有注册的元素
var $this = $ (this);
if ($this. offset () . top - $ (window) . scroll Top () > documen t, documen tElemen t. cl ien tHeigh t) { //不需要立即呈现
lazy, push ($this); 〃暂存元素 } else {
replace ($this); 〃呈现元素
}
});
$ (window) . one scrolF , function () { / / 面滚动 时, 呈现所存储的注册的元素
$. each (lazy, replace);
Figure imgf000008_0001
}
};
} ();
</script>
$ (function () {
lazy load. ini t O; //延时呈现初始
});
</script> </html〉 下面结合图 2说明根据本发明的一个实施例的、 适于解决上述问题的一种 在浏览器中处理页面的设备 200。
如图 2所示, 本发明的在浏览器中处理页面的设备 200包括: 元素注册器
210、 元素解析和渲染判定器 220、 元素解析和渲染器 230、 元素呈现器 240和元 素暂存器 260。
其中, 元素注册器 210被配置为对页面中需要延时呈现的元素进行注册。 可选地,需要延时呈现的元素可以是文字、图像(静态图像和动态图像)、 Flash 动画、 声音、 视频、 表格、 导航栏和交互式表单中的任意一种。 在一些实施例 中, 元素注册器 210将需要延时呈现的元素嵌入到自定义类型的 scr ipt标签中 来进行注册。 其代码如下:
< script type=" lazyload" >
这里是要延时呈现的 HTML代码
</script>
元素解析和渲染器 230被配置为在浏览器中解析和渲染该页面中未注册的 元素以及需要解析和渲染的在元素注册器 210中注册的元素。 可选地, 未注册 的元素可以是文字、 图像(静态图像和动态图像)、 Flash动画、 声音、 视频、 表格、 导航栏和交互式表单中的任意一种。 该元素解析和渲染器 230负责取得 网页的内容(HTML、 XML, 图像等等) 、 整理信息(例如加入 CSS等) , 以及计 算网页的显示方式然后会输出至电子设备的显示屏, 元素解析和渲染器 230可 以是 Tr ident排版引擎(是微软的视窗操作系统( Windows )搭载的网页浏览器 — Internet Exp lorer的排版引擎的名称) , 也可以是 Gecko排版引擎(是套开 放源代码的、 以 C++编写的网页排版引擎) 。 当然可以理解的是, 在本发明的 实施例中并不限定元素解析和渲染器 230的具体类型。
元素解析和渲染判定器 220被配置为判断是否要解析和渲染所注册的元 素, 如果要解析和渲染, 则由元素解析和渲染器 230在浏览器中解析和渲染所 注册的元素。可选地,所注册的元素可以是文字、图像(静态图像和动态图像)、 Flash动画、 声音、 视频、 表格、 导航栏和交互式表单中的任意一种。 在一些 实施例中, 在浏览器中由元素解析和渲染器 230解析和渲染该页面中未注册的 元素, 解析和渲染完成后, 由元素解析和渲染判定器 220判断注册的元素是否 需要解析和渲染,如果需要对注册的元素立即呈现(位于浏览器的当前窗口或 向下滚动页面) , 则由元素解析和渲染器 230对需要解析和渲染的注册的元素 进行解析和渲染, 然后由元素呈现器 240对所解析和渲染的非注册的元素以及 所解析和渲染的注册的元素进行呈现; 如果元素解析和渲染判定器 220判断不 需要对注册的元素立即呈现,则将不需要解析和渲染的注册的元素存储到元素 暂存器 260中, 等待合适时机(例如当浏览器的当前窗口上呈现的内容发生变 化时)再进行呈现, 部分实现代码如下:
//遍历所有元素注册器里的元素
$ script [type=lazyload] / ) . each (function () {
var $this = $ (this) ;
//不是浏览器的当前窗口或用户滚动到的元素
if ($this. offse t (). top - $ (window) . scroll Top () > documen t. documen t Elemen t, cl ien tHeigh t) {
〃不需立即呈现的元素放入元素暂存器中
lazy, push ($this);
} else {
//否则, 立即呈现
replace ($this);
}
});
在一些实施例中, 元素解析和渲染判定器 220通过判断所注册的元素是否 位于浏览器的当前窗口中来判断是否要解析和渲染所注册的元素。在另一些实 施例中, 元素解析和渲染判定器 220也通过判断所述页面是否在浏览器的窗口 中滚动来判断是否要解析和渲染所注册的元素。
元素呈现器 240被配置为呈现由元素解析和渲染器 230所解析和渲染的、位 于浏览器的当前窗口中的元素。 在一些实施例中, 当需要呈现元素时(浏览器 当前窗口呈现完成或用户向下滚动页面时),将存储的元素移交给元素呈现器 240进行呈现, 部分实现代码如下:
var replace = function(ele){
ele = typeof ele = = 'object'? ele: this;
ele. replaceWith( ele. val( ) 11 ele. html( ) );
};
元素暂存器 260被配置为存储元素解析和渲染判定器 220判断为不解析和 渲染的已注册元素。
在一些实施例中, 当浏览器的当前窗口上呈现的内容发生变化时,元素解 析和渲染判定器 220判断是否要解析和渲染元素暂存器 260所存储的已注册的 元素, 如果要解析和渲染, 则由元素解析和渲染器 230来解析和渲染由元素暂 存器 260存储的已注册的元素。
在此提供的算法和显示不与任何特定计算机、虚拟系统或者其它设备固有 相关。 各种通用系统也可以与基于在此的示教一起使用。 根据上面的描述, 构 造这类系统所要求的结构是显而易见的。此外, 本发明也不针对任何特定编程 语言。 应当明白, 可以利用各种编程语言实现在此描述的本发明的内容, 并且 上面对特定语言所做的描述是为了披露本发明的最佳实施方式。
在此处所提供的说明书中, 说明了大量具体细节。 然而, 能够理解, 本发 明的实施例可以在没有这些具体细节的情况下实践。在一些实例中, 并未详细 示出公知的方法、 结构和技术, 以便不模糊对本说明书的理解。
类似地,应当理解, 为了精筒本公开并帮助理解各个发明方面中的一个或 多个,在上面对本发明的示例性实施例的描述中, 本发明的各个特征有时被一 起分组到单个实施例、 图、 或者对其的描述中。 然而, 并不应将该公开的方法 解释成反映如下意图:即所要求保护的本发明要求比在每个权利要求中所明确 记载的特征更多的特征。 更确切地说, 如下面的权利要求书所反映的那样, 发 明方面在于少于前面公开的单个实施例的所有特征。 因此, 遵循具体实施方式 的权利要求书由此明确地并入该具体实施方式,其中每个权利要求本身都作为 本发明的单独实施例。
本领域那些技术人员可以理解,可以对实施例中的设备中的模块进行自适 应性地改变并且把它们设置在与该实施例不同的一个或多个设备中。可以把实 施例中的模块或单元或组件组合成一个模块或单元或组件,以及此外可以把它 们分成多个子模块或子单元或子组件。 除了这样的特征和 /或过程或者单元中 的至少一些是相互排斥之外, 可以采用任何组合对本说明书(包括伴随的权利 要求、摘要和附图)中公开的所有特征以及如此公开的任何方法或者设备的所 有过程或单元进行组合。除非另外明确陈述,本说明书(包括伴随的权利要求、 摘要和附图)中公开的每个特征可以由提供相同、等同或相似目的的替代特征 来代替。
此外, 本领域的技术人员能够理解,尽管在此所述的一些实施例包括其它 实施例中所包括的某些特征而不是其它特征,但是不同实施例的特征的组合意 味着处于本发明的范围之内并且形成不同的实施例。例如,在下面的权利要求 书中, 所要求保护的实施例的任意之一都可以以任意的组合方式来使用。
本发明的各个部件实施例可以以硬件实现,或者以在一个或者多个处理器 上运行的软件模块实现,或者以它们的组合实现。本领域的技术人员应当理解, 可以在实践中使用微处理器或者数字信号处理器(DSP )来实现根据本发明实 施例的在浏览器中处理页面的设备中的一些或者全部部件的一些或者全部功 能。本发明还可以实现为用于执行这里所描述的方法的一部分或者全部的设备 或者装置程序(例如, 计算机程序和计算机程序产品)。 这样的实现本发明的 程序可以存储在计算机可读介质上, 或者可以具有一个或者多个信号的形式。 这样的信号可以从因特网网站上下载得到, 或者在载体信号上提供, 或者以任 何其他形式提供。 智能电子设备。 该智 电子殳备传统上包括处理器 310和以存 ^者器 320形式 的计算机程序产品或者计算机可读介质。 存储器 320可以是诸如闪存、 EEPROM (电可擦除可编程只读存储器)、 EPROM、 硬盘或者 ROM之类的 码 331的存储空间 330。 例如, 用于程序代码的存储空间 ^30可以包括分别用 一 ^或者多个计算机程 产品中读 或者写入到这一个或者多个计^ 程 序产品中。 这些计算机程序产品包括诸如硬盘, 紧致盘(CD ) 、 存储卡或 者软盘之类的程序代码载体。这样的计算机程序产品通常为如参考图 4所述 的便携式或者固定存储单元。该存储单元可以具有与图 3的智能电子设备中 的存储器 320类似布置的存储段或者存储空间等。程序代码可以例如以适当 序^ 1,Γ即可以由例如诸如 310之类的处理器读取的代码, 这些代码当由智 能电子设备运行时, 导致该智能电子设备执行上面所描述的方法中的各个 步骤。
应该注意的是上述实施例对本发明进行说明而不是对本发明进行限制,并 且本领域技术人员在不脱离所附权利要求的范围的情况下可设计出替换实施 例。在权利要求中, 不应将位于括号之间的任何参考符号构造成对权利要求的 限制。单词 "包含"不排除存在未列在权利要求中的元件或步骤。位于元件之 前的单词 "一"或 "一个"不排除存在多个这样的元件。本发明可以借助于包 括有若干不同元件的硬件以及借助于适当编程的计算机来实现。在列举了若干 装置的单元权利要求中,这些装置中的若干个可以是通过同一个硬件项来具体 体现。 单词第一、 第二、 以及第三等的使用不表示任何顺序。 可将这些单词解 释为名称。

Claims

权 利 要 求
1、 一种在浏览器中处理页面的方法, 包括步骤:
对页面中需要延时呈现的元素进行注册;
在浏览器中解析和渲染该页面中未注册的元素;
判断是否要解析和渲染所注册的元素,如果要解析和渲染, 则在浏览器中 解析和渲染所注册的元素, 否则存储所注册的元素; 以及
呈现所解析和渲染的、 位于浏览器的当前窗口中的元素。
2、根据权利要求 1所述的方法, 其中所述对页面中需要延时呈现的元素进 行注册的步骤包括:
将需要延时呈现的元素嵌入到自定义类型的 scr ipt标签中。
3、 根据权利要求 1或者 2所述的方法, 其中, 所述判断是否要解析和渲染 所注册的元素包括步骤:
判断所注册的元素是否位于浏览器的当前窗口中。
4、 根据权利要求 1或者 2所述的方法, 其中所述判断是否要解析和渲染所 注册的元素包括步骤:
判断所述页面是否在浏览器的窗口中滚动。
5、 根据权利要求 1-4中任一个所述的方法, 还包括步骤,
当浏览器的当前窗口上呈现的内容发生变化时,判断是否要解析和渲染所 存储的已注册的元素, 如果要解析和渲染, 则解析和渲染所注册的元素。
6、 一种在浏览器中处理页面的设备, 包括:
元素注册器, 被配置为对页面中需要延时呈现的元素进行注册; 元素解析和渲染器,被配置为在浏览器中解析和渲染该页面中未注册的元 素;
元素解析和渲染判定器, 被配置为判断是否要解析和渲染所注册的元素, 如果要解析和渲染,则由所述元素解析和渲染器在浏览器中解析和渲染所注册 的元素;
元素暂存器,被配置为存储所述元素解析和渲染判定器判断为不解析和渲 染的已注册元素; 以及
元素呈现器,被配置为呈现由元素解析和渲染器所渲染的、位于浏览器的 当前窗口中的元素。
7、如权利要求 6所述的设备, 其中所述元素注册器将需要延时呈现的元素 嵌入到自定义类型的 scr ipt标签中来进行注册。
8、 如权利要求 6或者 7所述的设备, 其中所述元素解析和渲染判定器通过 判断所注册的元素是否位于浏览器的当前窗口中来判断是否要解析和渲染所 注册的元素。
9、 如权利要求 6或者 7所述的设备, 其中所述元素解析和渲染判定器通过 判断所述页面是否在浏览器的窗口中滚动来判断是否要解析和渲染所注册的 元素。
10、 根据权利要求 6-9中任一所述的设备, 其中当浏览器的当前窗口上呈 现的内容发生变化时,所述元素解析和渲染判定器判断是否要解析和渲染所述 元素暂存器所存储的已注册的元素,如果要解析和渲染, 则由所述元素解析和 渲染器来解析和渲染由所述元素暂存器存储的已注册的元素。
11、 一种计算机程序, 包括计算机可读代码, 当智能电子设备运行所述计 算机可读代码运行时, 导致权利要求 1-5中的任一项权利要求所述的方法被执 行。
12、 一种计算机可读介质, 其中存储了如权利要求 11所述的计算机程序。
PCT/CN2013/089352 2012-12-14 2013-12-13 在浏览器中处理页面的方法及设备 Ceased WO2014090187A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201210544985.5 2012-12-14
CN201210544985.5A CN103019720B (zh) 2012-12-14 2012-12-14 在浏览器中处理页面的方法及设备

Publications (1)

Publication Number Publication Date
WO2014090187A1 true WO2014090187A1 (zh) 2014-06-19

Family

ID=47968358

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2013/089352 Ceased WO2014090187A1 (zh) 2012-12-14 2013-12-13 在浏览器中处理页面的方法及设备

Country Status (2)

Country Link
CN (1) CN103019720B (zh)
WO (1) WO2014090187A1 (zh)

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103034723A (zh) * 2012-12-14 2013-04-10 北京奇虎科技有限公司 页面呈现方法及设备
CN103019720B (zh) * 2012-12-14 2017-11-17 北京奇虎科技有限公司 在浏览器中处理页面的方法及设备
CN103164541B (zh) * 2013-04-15 2017-04-12 北京世界星辉科技有限责任公司 图片呈现方法及设备
CN104133884B (zh) * 2014-07-28 2017-12-26 百度在线网络技术(北京)有限公司 显示网页的方法及装置
CN105792002B (zh) * 2014-12-18 2019-07-02 广州市动景计算机科技有限公司 视频渲染方法及装置
CN106293686B (zh) * 2015-06-25 2019-08-02 阿里巴巴集团控股有限公司 代码文本中展示图片注释的方法及装置
WO2018058614A1 (zh) * 2016-09-30 2018-04-05 深圳市华傲数据技术有限公司 页面渲染方法及装置
CN114817807B (zh) * 2022-04-27 2024-12-20 中国建设银行股份有限公司 页面处理方法、装置、设备、可读存储介质和产品

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030014478A1 (en) * 2001-06-29 2003-01-16 Noble Alan C. Dynamically distributed client-server web browser
US6657647B1 (en) * 2000-09-25 2003-12-02 Xoucin, Inc. Controlling the order in which content is displayed in a browser
CN102663126A (zh) * 2012-04-23 2012-09-12 奇智软件(北京)有限公司 一种在移动终端中显示网页的方法及装置
CN103019720A (zh) * 2012-12-14 2013-04-03 北京奇虎科技有限公司 在浏览器中处理页面的方法及设备
CN103034723A (zh) * 2012-12-14 2013-04-10 北京奇虎科技有限公司 页面呈现方法及设备

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102255745A (zh) * 2011-01-18 2011-11-23 北京开心人信息技术有限公司 一种管理js或css文件的方法及系统

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6657647B1 (en) * 2000-09-25 2003-12-02 Xoucin, Inc. Controlling the order in which content is displayed in a browser
US20030014478A1 (en) * 2001-06-29 2003-01-16 Noble Alan C. Dynamically distributed client-server web browser
CN102663126A (zh) * 2012-04-23 2012-09-12 奇智软件(北京)有限公司 一种在移动终端中显示网页的方法及装置
CN103019720A (zh) * 2012-12-14 2013-04-03 北京奇虎科技有限公司 在浏览器中处理页面的方法及设备
CN103034723A (zh) * 2012-12-14 2013-04-10 北京奇虎科技有限公司 页面呈现方法及设备

Also Published As

Publication number Publication date
CN103019720A (zh) 2013-04-03
CN103019720B (zh) 2017-11-17

Similar Documents

Publication Publication Date Title
CN103019720B (zh) 在浏览器中处理页面的方法及设备
CN103164541B (zh) 图片呈现方法及设备
CN103853417B (zh) 网络动态图片的滚动分页显示方法和装置
EP2164008A2 (en) System and method for transforming web page objects
US9697562B2 (en) Resource provisioning for electronic books
CN102346782A (zh) 在用户终端浏览器上按需显示图片的方法及装置
US9195772B2 (en) Delayed image decoding
CN103024038B (zh) 用于浏览网页的方法及装置
CN103761277A (zh) 一种ePub电子书的加载方法和系统
CN104809123B (zh) 一种网页渲染方法及系统
US9996512B2 (en) Customized processing of DOM objects
CN106874023B (zh) 动态页面加载方法和装置
CN102999336A (zh) 应用界面实现方法和系统
TWI539302B (zh) 用於網路服務的延後資源當地語系化連結
CN103856507A (zh) 网络动态图片的静态显示方法和装置
CN103024036A (zh) 网页浏览方法及装置
CN103034723A (zh) 页面呈现方法及设备
CN102929952B (zh) 网页图片显示装置和方法
CN106502968A (zh) 数据处理的方法及装置
KR102311326B1 (ko) 웹 컨텐츠 출력 장치 및 방법
CN104199862B (zh) 基于内容提供方定制的搜索方法、服务器和系统
CN105183883B (zh) 页面加载方法和装置
CN103530289A (zh) 网页显示方法和装置
CN102929777A (zh) 网络应用测试方法及测试系统
CN102929776B (zh) 对网络应用进行测试的测试方法及测试设备

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 13862122

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 13862122

Country of ref document: EP

Kind code of ref document: A1