Efficient web front-end development book
Pagespeed is a free tool performance analysis from Google.
Timeline the time it takes to interact and render web pages
Profile who can view the Web page CPU and Memory occupancy report
Audits provides a list of optimization recommendations and unused CSS rules for various resources and configurations
Compression of code
The text server turns on gzip compression.
UGLIFYJS is not just a compression tool, colleague with JS parsing and code beauty chemical energy
Image compression tool with online tools mostly tinypng compressed PNG format pictures.
Use Jpegmini to compress jpg format pictures
Local applications recommend the use of Imageoptim
The release phase can also be used to build code and resource compression tasks with Ant.
ID with _ Connect class with-connect.
The CSS file header can also be written with comments and explanatory notes.
File version copyright information Author, etc.
JS Comment
The local variable uses the first character lowercase other words the first letter capitalization way
Object-oriented private interface lowercase public interface uppercase.
Prefix the jquery variable with $
Verify page Barley
HTML validator automatically corrects and beautify your code
Better semantics
Replace <s> <strike> with <del>
<abbr> represents an abbreviated abbreviation for the label content
<noscript> indicates that no JS is used. Alternative, but sometimes it's ineffective.
A good practice is to not use JavaScript when the value of the server has a service period to calculate the return
can set the page in the case of disabling JS to jump Web page Baidu's approach is
<noscript><meta http-equiv = "Refresh" content = "0; Url=/baidu.html?from=noscript "/></noscript>
Properties of Meta
Name Meta information
HTTP-EQUIV Command Request
Content
CharSet character encoding
Name content constituent name/value pairs are used to describe site information
Name includes Application-name author description generator
HTTP-EQUIV Properties and Content property combinations, setting specific HTTP directives
Content-type Default-style (rarely used) refresh (first three confirmed) Content-language Set-cookie
<meta http-equiv= "Refresh" content = "+" > 5 minutes after Refresh
Be sure to set the charset before the <title> tag
You can manually set some pages of compatibility mode is not nonstandard but is commonly used meta
<meta http-equiv= "x-ua-compatible" content= "ie=8"/> Start support from IE8
Activates chrome frame in IE9 and the following browsers to force IE to render pages with chrome frame
<meta http-equiv= "x-ua-compatible" content= "chrome = 1"/>
Is that the device appears normal on the mobile device
<meta name= "Viewport" content= "width = Device-width,initial-scale = 1,maximum-scale = 1" >
Features of the fixed website of IE browser
<meta name= "Misapplication-task" content= "name=" Xinxianshi "action-uri=http://www.renren.com/home;icon-uri= Http://a.xnimg.cn/n/res/icons/newsfeed.ico "/>
Semantic tags
Div and span are not semantically
In CSS, you can use the content= "|" To set the content without having to put everything in the HTML
. spliter:before
: The before selector inserts content in front of the content of the selected element.
Use the Content property to specify what you want to insert.
Using label implementations that are smooth and degraded and semantically
<li class= "Reader-action-library" >libarary</li> also because the text does not show
. reader-main-action li{
text-indent:-99999px;
}
Do not display text when CSS is disabled when CSS is disabled to display smoothly
New tags added to HTML
Improve the semantics of HTML important attributes alt title
The element above is one on the left and the lower right element to be unaffected by the above element.
Need to clear floating clear:both first;
Text-indent to achieve the purpose of shadow-hiding text
Building a login table using table tags Tan ambiguous and bloated code
It is best to use label to display the text label of the login form
The label implementation associated with a for back point to the associated tag ID has great advantages in both the radio box and the multi marquee
<form>
<fieldset disabled>//form grouping and disallow input
<legend> Health Information </legend>//title Information
Height: <input type= "text"/>
Weight: <input type= "text"/>
</fieldset>
</form>
TabIndex setting tab order Toggle
Required = ' true ' that the input cannot be empty
Block elements can contain other elements
Inline elements can only contain inline elements
HTML5 don't have to remember these more semantic memories.
HTML5 <meta charset= "UTF-8" >//indicates the definition of page encoding
<meta http-equiv= "content-type" content = "Text/html;chars=utf-8" in HTML4.01 >
become more concise and convenient
HTML5 Introducing CSS style sheets
<link rel= "stylesheet" href= "/CSSDAFDA" >//Neither set type= "Text/css" again
Introducing JS
<strcipt src= "Afdaf.js" ></script>//type= "Text/javascript"
The new input type of space will be degraded smoothly
The two properties of script defer and async will only function if SRC is set.
Defer represents a parallel download and does not modify the DOM tree last loaded execution
Async means that the asynchronous load will execute immediately after the download is complete. Dependencies cannot be used
If the page has inline scripts that depend on the loaded script, it is not appropriate to use the Defer property.
<base> set the default target for a tag such as _blank
Property value Custom Data-length= "XX" reads this property value. dataset[' length ' Set the same
<i> <b> <u> <small> italic bold underline small font
H5 has a lot of tags discarded strike and big.
There are also some properties of the labels being removed
IE old can be generated by the Createlement method of the label
Framework support H5 Old browser Html5shim
MODERNIZR represents a framework for monitoring new features
Type is the total class and format name
<SOURC src= "Video.mp4" type= "Video/mp4" >
<iframe Insert some things >
Files in CSS a default style file a common file an IE-specific file
Reference this file in the page using the conditional comment method unique to IE browser
<!-[if LT IE 8]>
<link rel=stylesheet ' href= "Ie-style.css"/>
<! [endif]-->
To display a new label in HTML5 in IE89 normal to define a requirement in a display Cssreset
Yui frame seems very powerful.
Style sorting letters in CSS recommended from small to large
Sort by the size of the page influence the image layout in front does not affect the layout in the back
Csscomb CSS Free automatic sequencing program
CSS Weights
Id> class pseudo Class Property selector > Label type Pseudo-object > wildcard character
CSS that is reused as much as possible without the ID selector reduces
In order to improve the priority of the compatibility style can be more elements
<!-[if LT ie 8]>//There is also a method <!-[if GT ie 8]><!-->
<! [endif]-->
Relative units and absolute units px pt cm mm in PC
Relative unit Windows relative unit VW VH vmin Vmax font relative unit em ex ch REM
Try to set the sex to size when the overall module changes, you do not need to change the dimensions of the module's internal submodule.
You can explicitly set the body font size to 16px after the sub-module with 0.8 em and the like
REM is a set of relative values based on the root element.
The CSS matching rules and our habits are reversed from right to left.
Avoid using wildcard characters *
Because the ID selector is unique before adding the tag name to the unconscious superfluous increase the matching time
CSS selectors test represents the cost of testing CSS
Try not to set the size of the picture the cost of the CPU rendered by the system
Thumbnails and normal large pictures do not use the same picture to be divided into two pictures
Sprint Map Recommended Length * width = 2500 Sprite Chart Best control within 200k picture attitude AH will consume more transmission time
Csssprit Generator Generator Online
CSS Sprit Cow sprite map CSS Code generator
Spriteme generate sprite graphs and corresponding CSS code by analyzing Web Sites * * * * * * * * * good
CSS Many properties are inheritable color font line-heighttext-align text-tansform
Chrome can have tools to make unnecessary CSS
Remove unused cssrules in audits
For a specific browser prefix-webkit Chrome Safari
Firefox-moz
Ie-ms Opera-o
Automating the addition of browser prefixes
PERFIXR AUTOPERFIXR
Suggested sites for Html5please
Js
Avoid global variable contamination encapsulated in a variable object above var mycurrentaction = {
length:0,
Init:function () {},
Action:function () {}
}
var Mycurr = (function () {
var length = 0;
function init () {}
function action () {}
The return init:init;//external code access init () method is available by calling Mycurr.init to return the exposed interface
})()
Null and undefined themselves compare to each other as true
Primitive types (numeric, Boolean, character types) are converted to numeric types for comparison
object is compared with the original type when the object is compared to the original type
With (object) {
}
When JS runs, it will create a separate variable for the function to be used as a local variable.
Avoid using with only the runtime to know that the variable belongs to that object
With compatibility issues, ECMA 5 and 6 are implemented differently on the width [] parameter
Eval ("x = 1;y = 2;x*y") is the execution of the contents of the string as code. There are security issues
It is best not to write browser judgment logic directly detect browser feature support
Just add the following in the script
"Use strict";
It is best not to use strict mode in the global
Preferably written in a function.
JS Code checker tool Jshint
JS can be set obj.style.cssText + = "border:1px solid #f00"
The above is not a best practice best practice is to change the class
Generating an inner child element of an element by InnerHTML
<script id = "XXX" type= "Text/x-tmpl" >
</script>
When you need to get the template code through
var infotemplate = document.getElementById (' Main_info '). InnerHTML;
<template> tags in HTML5
Mustache Template System
MVC CMV
JS Modular specification mainly has two kinds of commonjs and AMD
Synchronous and asynchronous load modules a major use in the server and a primary use in the front end
The JS library that implements the AMD module is mainly Requirejs
Ajax can't abuse otherwise replace y an entire UI can be changed page break the back button on the browser jquery has related plugins
JS is a single-threaded blocking state downloaded and loaded
It is recommended to put JS at the bottom of the body
Defer
Tell the browser that this JS code will not produce any page content, so the browser can continue to parse the page's subsequent content as it loads the reference.
Load on Demand
Use less Forin
JS does not exist block scope
When multiple functions are nested defined, a scope contains a relationship called a scope chain
Internal function Multiple external data well shorthand for one
var doc = document;
Prototype prototype object
The properties and methods on the instance come from itself and the corresponding prototype object.
Frequent reads of objects and properties on the prototype chain can affect performance.
DOM and JS are modules that are stored in two unrelated modules, resulting in a loss of performance
and Dom rearrangement and redrawing can also lead to a loss of performance.
Dom additions and deletions and modifications of the DOM elements are visible.
Requesting DOM element layout information can result in a very good performance loss Offersettop ClientX
Frequently modifying DOM styles
Ele.style.border .....
Not advocating merger as a
Optimization change classname Csstext + =
Cloning DOM Memory operations
var old = Document.daadfafdsaf
var clone = Old.clonenode (true);
The animation effect is set to fixed or absolute to avoid page re-arrangement.
Too many event bindings can result in poor performance. It is best to use the bubbling mechanism to bind events on the parent element, which is the event managed
Using the Timeline tool chrome
Online Code Performance analysis tool JsPerf
Common web front-end attack methods
XSS do everything you can to run code on a browser page that is not a browser
CSRF can not participate without JS
Ddos
Hijack above an IFRAME overlay
Cookie set to HttpOnly prohibit JS operation Cookie
Viewport support for the mobile side
Compatible mobile end use streaming layout percent fixed width
Borrowing media queries Technology
@media (max-wdith:600px) {
. facet_sidebar{
Display:none;
}
}
/* Display specific html*/by writing the appropriate media query from large to small above
A different set of pixels than a clear picture
@media only screen Animation-delay: (min-device-pixel-radio:1.5) {
#my-image{
Background:url (high.png);
}
}
/* You can also use the image method */
Background-image:image-set (
/* Indicates a pixel ratio of 1 and 2 */
URL (icon1x.jpg) 1x,
URL (icon2x.jpg) 2x
);
More is the use of technical library Picturefill
BOOTSTAP-Responsive Design related
Howtogomo checking the compatibility effect of websites on mobile devices
Mobile site generally choose the desktop side of the site's two-level domain name m start
Monitor information use-agent for mobile devices
Design a mobile app to avoid page jumps for single-page mode
Mobile Development Framework jquery Mobile
Chrome has the technology to enable the phone to open Debug and start debugging on the computer side
Want the browser to automatically recognize the phone number
<meta name= "format-detection" content= "Telephone=yes" >
<a href= "tel:1-406-666-xxxx" >ddafdaf</a> Telephone
<a href= "sms:1-406-666-xxxx" >ddafdaf</a> SMS
Use table and IFRAME as little as possible on the mobile side
Use UL ol instead
Font Awesome for chart type
Inline picture Base64
Some do not need to long press the way out of the dialog box
User-select:none;
Mouse related events have corresponding gesture-related events
The tab event is a simulation of the Click event because the Click event causes a 300ms delay on the mobile side
There is also a Tabhold event through practice to determine which event ~
Avoid using a timer to accomplish tasks that require accurate control of time during web mobile development.
Getting Started book Web front-end development Best practices