OLD | NEW |
1 <h1>Event Pages</h1> | 1 <h1>Event Pages</h1> |
2 | 2 |
3 | 3 |
4 <p> | 4 <p> |
5 Event pages are very similar to | 5 Event pages are very similar to |
6 <a href="background_pages.html">background pages</a>, | 6 <a href="background_pages.html">background pages</a>, |
7 with one important difference: | 7 with one important difference: |
8 event pages are loaded only when they are needed. | 8 event pages are loaded only when they are needed. |
9 When the event page is not actively doing something, | 9 When the event page is not actively doing something, |
10 it is unloaded, freeing memory and other system resources. | 10 it is unloaded, freeing memory and other system resources. |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 API or issuing a network request). Additionally, the | 83 API or issuing a network request). Additionally, the |
84 event page will not unload until all visible views (for example, | 84 event page will not unload until all visible views (for example, |
85 popup windows) are closed and all message ports are closed. Note | 85 popup windows) are closed and all message ports are closed. Note |
86 that opening a view does not cause the event page to load, but | 86 that opening a view does not cause the event page to load, but |
87 only prevents it from closing once loaded. | 87 only prevents it from closing once loaded. |
88 </p> | 88 </p> |
89 | 89 |
90 <p> | 90 <p> |
91 Make sure your event page closes as soon as the event that | 91 Make sure your event page closes as soon as the event that |
92 opened it is processed. | 92 opened it is processed. |
93 You can observe the lifetime of your event page by clicking | 93 You can observe the lifetime of your event page by |
94 on "View Background Pages" in the Chrome menu, or by | |
95 opening Chrome's task manager. You can see when your event | 94 opening Chrome's task manager. You can see when your event |
96 page loads and unloads by observing when an entry for your | 95 page loads and unloads by observing when an entry for your |
97 extension appears in the list of processes. | 96 extension appears in the list of processes. |
98 </p> | 97 </p> |
99 | 98 |
100 <p> | 99 <p> |
101 Once the event page has been idle a short time | 100 Once the event page has been idle a short time |
102 (a few seconds), the | 101 (a few seconds), the |
103 <code>$ref:runtime.onSuspend</code> | 102 <code>$ref:runtime.onSuspend</code> |
104 event is dispatched. The event page has a few more seconds to handle this | 103 event is dispatched. The event page has a few more seconds to handle this |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 <code>$ref:contextMenus.create</code>. | 211 <code>$ref:contextMenus.create</code>. |
213 | 212 |
214 <li>Remember to test that your event page works properly when it is unloaded | 213 <li>Remember to test that your event page works properly when it is unloaded |
215 and then reloaded, which only happens after several seconds of inactivity. | 214 and then reloaded, which only happens after several seconds of inactivity. |
216 Common mistakes include doing unnecessary work at page load time (when it | 215 Common mistakes include doing unnecessary work at page load time (when it |
217 should only be done when the extension is installed); setting an alarm at | 216 should only be done when the extension is installed); setting an alarm at |
218 page load time (which resets any previous alarm); or not adding event | 217 page load time (which resets any previous alarm); or not adding event |
219 listeners at page load time. | 218 listeners at page load time. |
220 </ol> | 219 </ol> |
221 </p> | 220 </p> |
OLD | NEW |