Tip #1: Replace search codes with queries.
You were used to using functions such as
HReadSeek,
HReadNext to search your data files, to carry out complex processing, ... The processing required to search and display the search result could easily take dozens of lines of code.
Use the queries! Create your query in the query editor and associate this query with the page or with the type of control (Looper, Table, List Box, etc.).
Use the queries to optimize your searches. When performing reload operations, the queries are much faster.
Tip 2: Use RepeatString fields in the file to display your data.
To display data from queries or files in RepeatString fields, use the RepeatString fields in the file directly (don't program your RepeatString fields by hand!). All you have to do in the page editor is indicate the file or basic query associated with the Page control, the items to be displayed, etc., and that's it.
The code for filling the Looper control when browsing the file is not necessary. WEBDEV takes care of everything and the display of Looper controls is much faster.
Tip #3: Delete HCreationIfNotFound from your code.
Is this function really useful in a dynamic WEBDEV website? No, because most of the time, files are already created and installed on the Web server when using the site.
Therefore, this function can be deleted from your code without consequences.
Tip #4: Reduce the project initialization code (and move it to the page initialization code).
Reduce the project initialization code: the first dynamic page will be displayed much faster.
Tip N°5: Limit project global variables and context variables (in AWP sites).
The global variables of the project are declared and loaded in memory as soon as the site is started. Whenever a global variable is used, the process time on the server is not insignificant.
Furthermore, the global variables use the memory resources of the server.
In the AWP sites, the use of
DeclareAWPContext to store data between several successive queries is slowing down. Indeed, the data must be re-read by each query. Furthermore, if the mode for storing the AWP context (chosen in
ConfigureAWPContext) is a management by cookie, the content of the context is returned from the browser to the application server whenever a query is run, so the site is even more slowed down.
Tip 6: Replace hidden fields with global page variables.
If a page uses hidden controls to manipulate information, we advise you to delete these controls and to replace them by global page variables for example. Indeed, the HTML code corresponding to a control (even hidden) is larger than the code for the global page variables.
Tip #7: Change pages not using server code into static pages.
If you are using no server code in a page and no controls specific to dynamic pages, create a static page. The size of the corresponding HTML file will be smaller.
Tip #8: Use PageRefresh rather than PageDisplay.
PageRefresh and PageDisplay both open a page in a window of the browser:
- PageDisplay creates the page context on the server again and runs the initialization code of the page.
- PageRefresh creates the page context and runs the initialization code of the page if necessary. Therefore, this function is faster.
Replace PageDisplay by PageRefresh when possible.
Warning: The PageRefresh function does not open a set page.
Tip #9: Avoid useless browser procedures and functions.
The WLanguage functions used in browser code as well as the local browser procedures are converted into JavaScript code and are included in the pages in HTML format.
Therefore, the HTML code gets bigger as you use browser functions and procedures. Each function used slows down the loading time of your page.
Therefore, we advise you to:
- delete the useless browser WLanguage functions (for example, limit the use of Val(ExtractString(MyString)).
- group these processes in sets of browser procedures. Then, the corresponding code is saved in a unique JavaScript file, different from the page.
Tip #10: Use page templates to standardize the site pages.
The page templates are used to optimize the load time of the page as well as site maintenance. Indeed, using page templates in your sites allows you to:
- optimize the speed when displaying the pages of the site.
- limit the number of generated HTML files (and therefore the number of HTML files downloaded to the computer of the Web user).
- easily create the site pages.
- define the layout of the site pages.
- refresh the style book of the site.
- simplify the management of targets for the site pages.
- ...
Tip #11: Avoid framesets.
Today, very few Web sites use the framesets. Why? Mainly because of loading time. Indeed, the load time of a frameset is equivalent to the load time of all the pages that make up the frameset.
Furthermore, even though WEBDEV proposes a user-friendly interface for handling framesets, the result on the computer of the Web user depends on size of his browser. Scrollbars may appear, unexpected display effects may occur when the browser is resized, ...
Reserve the framesets for the Intranet sites!
Tip 12: Use the Cell control for background colors and borders.
You may be tempted to use images or an overlaid caption to draw borders or to define a background color of an area.
Use the new cell control. This control is loaded faster than an image and you can easily get all the required effects. Furthermore, to manipulate a control and a cell, there is no need to use the "Overlayable" option available for the controls.
The cell control generates less HTML code and therefore it optimizes the load time of your page.
Tip 13: Use the "Automatic" mode for fields.
WEBDEV proposes 3 different modes for each type of control:
- static mode: if the field is not modified by programming.
- dynamic mode: if the field is to be modified by programming.
- automatic mode: WEBDEV automatically detects whether you are manipulating the field programmatically and generates the corresponding HTML code. This last option is recommended because the generated HTML code is optimized according to the operations performed in your WEBDEV website.
Tip #14: Avoid using several CSS styles.
Be careful when designing the style sheet of your project and avoid using too many styles. Indeed, the more styles are used, the more time it takes to load a page (because the style characteristics of the.CSS file must be loaded).
Our tip: Use between 5 and 10 different styles on a site.
Tip #15: Avoid local styles.
When modifying the style of a control, it can be defined "locally". The modifications made to the style will only be applied to this control (and not to all the controls that use the CSS style).
A local style is directly defined in the HTML page. Therefore, a local style slightly increases the page size (and its load time).
Twenty local styles in a page increase the size of the page by more than 1 KB.
Tip #16: Replace Static controls with HTML Static controls.
You are using several static controls in order for the Web user to see a text with different layouts (part of the text in bold, part of the text in color, etc.).
Delete all your static controls and replace them by a single "HTML static control".
A single Page control replaces 3 or 4 fields: the HTML file corresponding to your page is immediately reduced in size, so it loads faster.
Tip 17: Use WEBDEV's page generation optimizations.
To optimize the size of the generated pages, WEBDEV proposes a set of optimization options to use on the pages of your project.
By default, the most common optimization options are applied to all the pages of the project. However, the optimization options can be customized:
- for all the project pages ("Project Description", "Advanced" button in the "General" tab).
- for a single page of the project ("Advanced..." in the "Style" tab of the page description window).
Tip #18: Check the image size
All the sites display images. These images play an important part in the load time of the page. On the Internet, the JPEG and PNG formats are recommended. These formats are compressed image formats.
To optimize the size of your images, use images in 100%. Avoid using images that will be reduced when displayed.
Let's see some examples of standard sizes according to the image resolution:
| |
Resolution (in pixels) | Recommended size (estimate in KB) |
---|
20 x 30 | 0.29 |
50 x 80 | 2 |
100 x 200 | 9.8 |
To check the size of all images associated with one of the site pages:
- Run the project and display the page in Internet explorer.
- On the "Inicio" tab, in the "General" group, click "Guardar" and select "Save as".
- Save the page in a new directory. The page in HTML format and all the image files used by the page are saved in this directory.
- Resize the images found in this directory.
Reminder A 4 kB file is displayed in 1 second by modem, so a 40 kB image is displayed in 10 seconds (for optimum use of the modem at constant speed).
Tip #19: Create images directly in GIF or JPEG format and save them in the "_WEB" directory.
To optimize the HTML code used to manage the images, we advise you to:
- directly create images in the desired format and size using image editing software.
- save these images directly in the _WEB subdirectory of the project.
- associate the Image control with the desired image in the control description window.
Note Avoid resizing, reducing, etc. images in the editor. Use images in 100%. The size of your images will be optimized for your site.
Tip N°20: Check the size of the generated page (it should be less than 50 Kb).
The size of the generated page corresponds to the size of the page displayed in the browser of the Web user (and not the size of the HTM file generated by WEBDEV).
To find out the size of the page displayed in the browser:
- Run the project and display the page in Internet explorer.
- Display the source code of the HTML page.
- Save the source code in a text file (in Notepad for example).
- Check the size of the file.
Note: It is not advisable to use the "Save as" option, as Internet browsers (e.g. Internet Explorer) add specific HTML code when saving the page.
Tip N°21: Think of the ruler.
A page containing a Table control or a Looper control displays all control records. To limit the number of records displayed in the page (and therefore limit the size of the HTML file returned by the server), use a pager.
The pager allows the Web users to display the different elements found in the Table control or in the Looper control.
No programming required. Simply add a Pager control and associate it with the desired Table or Looper control.
You should not use more than 10 rows per page.
Tip 22: Set a timeout for your dynamic sites during deployment.
The timeout corresponds to the amount of time after which the connection is automatically canceled if no action was performed by the Web user
This parameter must be defined according to your site. Indeed, each connection consumes server memory. To optimize the server memory, the unused connections should be closed quickly. In most cases, a timeout set to 10 minutes is enough.