This is a discussion on Website Performance Tips & Tricks within the Web Design Help forums, part of the Web Development category; Line breaks we want to know how they can retain textarea line breaks in HTML. You should store text in ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Line breaks we want to know how they can retain textarea line breaks in HTML. You should store text in the database in its original format (e.g. with just newlines) and then use nl2br() to convert newlines to HTML <br /> tags on display. That's all good, except for one problem with nl2br(): it doesn't seem to convert \r newlines (edit: this has now been fixed in PHP 4.2.0). Windows uses \r\n newlines; *nix uses \n; Mac uses \r. nl2br() works correctly on text from Windows/*nix because they contain \n. However, if you get text from a Mac, nl2br() will not convert its newlines (again, fixed in PHP 4.2.0). To remedy this, we should use the following bit of code to convert \r\n or \r to \n before inserting it into the database. It won't hurt anything and ensures that nl2br() will work on the \n only newlines on display. Also, it has the side effect of saving 1 byte in the database per newline from Windows (by storing only \n instead of \r\n). PHP Code:
__________________ J.Vijayanand |
| Sponsored Links |
| |||
| Quotes around numeric data in queries For numeric columns in MySQL, you shouldn't put quotes around any of their values in queries. As most legends says, "that is very non-standard and will only work on MySQL." But if it's unknown data, how do you know that it's numeric and not letters that will cause an error? You can make sure that only a number is used in the query by first type-casting the data as int (or float for decimal numbers): // If id is being passed in the URL $id = (int) $_GET['id']; $r = mysql_query("SELECT * FROM table WHERE id=$id"); Then even if id is set to "abc," the worst that can happen is a 0 will be used in the query. No quotes; no error.
__________________ J.Vijayanand |
| |||
| MySQL Column types and attributes 1) Be familiar with MySQL's column types along with their ranges/lengths. You should use the smallest column type that will hold the data that you expect to store. Most of the time, you probably don't need INT, because MEDIUMINT, SMALLINT, or TINYINT have enough range. Using a smaller type saves space and speeds things up. 2) Declare all of your columns NOT NULL unless you need to store NULL values (NULL is not the same as 0 or the empty string). If you need to store NULL, you'll know. Again, NOT NULL saves space and speeds things up. 3) Making INT-family columns UNSIGNED will effectively double the positive range with the same storage requirement. For example, TINYINT's highest value is 127. TINYINT UNSIGNED's highest value is 255.
__________________ J.Vijayanand |
| |||
| Efficient Query Design Thanks -Kathir |
| |||
| Very good contribution has been made to this thread and so ive made this thread sticky. Good Luck and continue quality content posting in this thread regularly because our goal must be to get the 1st result in search engines when searched for website performance or website performance tips. Thanks
__________________ Vinoth Chandar Creator of Discussweb |
| |||
__________________ J.Vijayanand |
| |||
| Hi all, In PhP, When you are working with String, if suppose want to check that the string contain certain length , you considerably use strlen() function. Of course, it is pretty quick method to calculate the length of string. However, it is somewhat slow because the function call require to refer in hash table lookup and then execute that function.why isset()? isset() is a language construct and not a function meaning that its execution doesnot refer the lookup table. This means that virtually you have no overhead on calculating the String lengthHow to acheive? Its simple, In the following Example, It check for the string having less than 15 character, if it so print 'string having less than 15 characters', PHP Code: PHP Code:
__________________ Regards, VELHARI I am not totally useless. I can be used for a bad example |
| |||
| Website Performance Tips & Tricks:
__________________ J.Vijayanand Last edited by vijayanand : 08-23-2007 at 05:40 AM. |
| |||
| Website Performance Tips & Tricks: Modify the following httpd.conf parameters to: PHP Code: PHP Code:
__________________ J.Vijayanand |
| |||
| Website Performance Tips & Tricks: # If you are comfortable patching Apache 1.3 sources, try lingerd. Each Apache process currently wastes a lot of time "lingering" on client connections, after the page has been generated and sent. Lingerd takes over this job, leaving the Apache process immediately free to handle a new connection. As a result, Lingerd makes it possible to serve the same load using considerably fewer Apache processes. # Increase SendBufferSize in httpd.conf to the size of your largest Web page. Increase your kernel's TCP/IP write buffer size.
__________________ J.Vijayanand |
| |||
| Have you ever waited for a slow Web page to load, given up, clicked the browser's "Stop" button, and then suddenly seen the page appear? Where was it all that time? Pages like that are a good example of how your HTML tags can affect your page load time. Reason: By now nearly everyone knows you should use HEIGHT and WIDTH attributes for your image tags. Using these attributes lets the browser allocate space for your image within the page layout. That way the browser can render the rest of the page, leaving a placeholder for the image while it's loading. HEIGHT and WIDTH attributes for your TABLE and TD tags are just as important, for exactly the same reason. These attributes tell the browser how much space to allocate for each table cell. Without them, the browser waits until all the table's contents have been loaded before rendering any of its contents.Thanks, Ramkumar.B Last edited by ramkumaraol : 08-23-2007 at 06:19 AM. |
| |||
| Hi I think every one knows display an output statement in php Print: The print () function is used to output the given argument. It can output all types of data and multiple outputs can be made with only one print () command. Echo: The echo () function is used to output the given argument. It can output all types of data and multiple outputs can be made with only one echo () command.
Thanks R.Rajan |
| |||
| Try to avoid nesting table.When you place a table inside another table, it takes a lot longer for the browser to work out the spacing since it has to wait to read the entire html and then work out the layout. If at all possible, try using CSS to create the columns on your page. Thanks, Ramkumar.B |
| |||
| Website performance Tips: Hardware and Monitoring :
__________________ J.Vijayanand |
| |||
| Website performance Tips: Hardware and Monitoring - 2 :
__________________ J.Vijayanand |
| |||
| Avoid CSS Expressions CSS expressions are a powerful (and dangerous) way to set CSS properties dynamically. They're supported in Internet Explorer, starting with version 5. As an example, the background color could be set to alternate every hour using CSS expressions. background-color: expression( (new Date()).getHours()%2 ? "#B8D4FF" : "#F08A00" ); As shown here, the expression method accepts a JavaScript expression. The CSS property is set to the result of evaluating the JavaScript expression. The expression method is ignored by other browsers, so it is useful for setting properties in Internet Explorer needed to create a consistent experience across browsers. The problem with expressions is that they are evaluated more frequently than most people expect. Not only are they evaluated when the page is rendered and resized, but also when the page is scrolled and even when the user moves the mouse over the page. Adding a counter to the CSS expression allows us to keep track of when and how often a CSS expression is evaluated. Moving the mouse around the page can easily generate more than 10,000 evaluations. One way to reduce the number of times your CSS expression is evaluated is to use one-time expressions, where the first time the expression is evaluated it sets the style property to an explicit value, which replaces the CSS expression. If the style property must be set dynamically throughout the life of the page, using event handlers instead of CSS expressions is an alternative approach. If you must use CSS expressions, remember that they may be evaluated thousands of times and could affect the performance of your page. Thanks, Ramkumar.B |
| |||
| Make JavaScript and CSS External: Should JavaScript and CSS be contained in external files, or inlined in the page itself? Using external files in the real world generally produces faster pages because the JavaScript and CSS files are cached by the browser. JavaScript and CSS that are inlined in HTML documents get downloaded every time the HTML document is requested. This reduces the number of HTTP requests that are needed, but increases the size of the HTML document. On the other hand, if the JavaScript and CSS are in external files cached by the browser, the size of the HTML document is reduced without increasing the number of HTTP requests. The key factor, then, is the frequency with which external JavaScript and CSS components are cached relative to the number of HTML documents requested. This factor, although difficult to quantify, can be gauged using various metrics. If users on your site have multiple page views per session and many of your pages re-use the same scripts and stylesheets, there is a greater potential benefit from cached external files. Many web sites fall in the middle of these metrics. For these properties, the best solution generally is to deploy the JavaScript and CSS as external files. The only exception I've seen where inlining is preferable is with home pages, such as Yahoo!'s front page (Yahoo!) and My Yahoo! (Sign Up - My Yahoo!). Home pages that have few (perhaps only one) page view per session may find that inlining JavaScript and CSS results in faster end-user response times. For front pages that are typically the first of many page views, there are techniques that leverage the reduction of HTTP requests that inlining provides, as well as the caching benefits achieved through using external files. One such technique is to inline JavaScript and CSS in the front page, but dynamically download the external files after the page has finished loading. Subsequent pages would reference the external files that should already be in the browser's cache. thanks, venkatbi |
| |||
| Two types of performance: 1)There's two different ways to look at a website's performance. First of all there's raw server performance. How many page request can a server handle before it collapses under load and more important: how fast can it process them. On a high volume website this aspect of performance is very important because it determines how many users a machine can serve before additional server capacity is needed. 2)The second way to look at performance is what we could call 'perceived performance'. It's the speed at which your site appears to perform to the user. Even if your server is capable of serving all files required to render your website's pages in a visitor's browser as fast as it gets, your site may still appear slow to the user. thanks, venkatbi |
| |||
| Hi all, I have designed the web page in asp.net using C#. When i run that page in FIREFOX, Horizontal scroll bar is appeared but in IE, its not appeared..... i want to disable the horizontal bar in FIREFOX.. How do i do.. Can anyone help me
__________________ Krishnakumar.S Beware of Everything -that is un true; stick to the Truth shall succeed slowly but steadily |
| |||
| Using single includes for several style sheets or scripts One solution is PHP script that does the job of collating several scripts or CSS style sheets into a single file.The script is dead easy to use and will cache the collated file for you until you change one of the files included in it. This means that your files are automatically packed, cached and the include file updated when you change them. You get the best of both maintenance and speed without having to change anything by hand. thanks, venkatbi |