A simple special effect caused by the Battle of the mobile development Why I gave up jquery mobile

Source: Internet
Author: User

I would like to be quiet as a handsome man, but the boss does not raise wages, instead, January than January.

Why do I give up the jquery mobile plugin to choose to write special effects? In the development of everyone knows the efficiency is very important, a good tool can greatly improve the efficiency in the development, the more work done, the corresponding remuneration will be more, the opposite is my own.
Recently has been on one thing, mobile Web site testing must be in line with 3 star, the unqualified site to ensure 3 stars, convenient online promotion, will inevitably meet some problems, roughly for the later part of the topic will write an essay summary, "Mobile development in the site how to optimize." One of the problems encountered is that the JS file is too large, the CSS file is too large, the previous project has been using the jquery mobile development front-end template, so that the bulk development of the template is based on jquery Mobile, there has been no excessive analysis of the problem between this, Until this assessment.
jquery Mobile is based on jquery and must be introduced into jquery before applying jquery mobile, in order to facilitate the natural use of the corresponding jquery mobile style files. But in the actual batch template does not write more JS effect, also does not use the jquery mobile default style, but also to write some style to remove the original style. (In fact, some of this can be avoided, do not mind the situation can still use JQM, but our small partners have a fixed task, the use of development for efficiency, a day may be completed two sets of templates, the corresponding time has been put on the CSS and template tags).
This article original blog address: http://www.cnblogs.com/unofficial official website address: www.pushself.com It turns out we did it. Mobile Development JS:
①jquery-1.9.1.min.js
②jquery.mobile-1.3.1.min.js
③banner.js
④ Section JS
Css:
①jquery.mobile-1.3.1.min.css
②style.css
This article original blog address: http://www.cnblogs.com/unofficial official website address: www.pushself.com Now I'm doing this. Between JQM and Zepto I still have a tangle, after all, there have been a lot of projects have been based on JQM, and finally I decided to use Zepto to re-standardize the next template, maybe I was just a person's idea, maybe this is just a thought to play, After all, this is not the first and the last time. Say it far, pull it back.
Js:
①require.js
②zepto.min.js
③touch.min.js
④baiyun.mobile.min.js
Css:
①style.css
This article original blog address: http://www.cnblogs.com/unofficial official website address: www.pushself.com Comparative analysis>>> Comparison one: page

Figure One, the original, in this version is used JQM, completely do not use the default UI JQM, instead of using a lot of independent IMG, but also naturally increased the number of requests, according to the current requirements, the page can not be a single design into the current banner, home column navigation. This will naturally increase the number of requests.

figure Two, current edition, in this version of the use of Zepto, just for the convenience of the selector, and better I think the use of native JavaScript, which is to do the benefits of mobile development, do not consider the pain of the low version of IE, the basic knowledge of the requirements will be more secure, perhaps accustomed to the use of tools, Sometimes it is difficult to tell whether there is such a method in the native, with the update, perhaps now being used will be replaced by the next, but the change is still there. Also used an old method is CSS Sprites, now there are some other ways, here for the moment not to repeat.
>>> Comparison II: First load

figure three, the original

Figure Four, current edition
>>> contrast three: two times load

Figure Five, the original

Figure Six, current edition
Contrast two and contrast three can not be absolute data, but we can see some problems, because it is also just facing the difficult problem of Samsung testing is now learning to sell, about the optimization of the site there is a lot of knowledge to learn, and hope to be able to work with the small partners to exchange. Here do not say other factors, otherwise there is far, figure three jqm and JQ file is 73.9K (the original file is also larger, specific can be found in the jquery official website), time spent about 1S, contrary to require and zepto and Touch file is 17.6K, time consuming 52ms, data should be able to see something? Finally I decided to change JQM, using the current version, plug-ins can also be used directly JQM plug-ins, more like their own wheels, the main hope in the process of self-learning, wages can not be reduced, ah, and then have to let people send a little, the news said the subway mouth begging days into how much, you may not be able to, There are too many problems involved, the simplest of which is that you have no experience in this field.This article original blog address: http://www.cnblogs.com/unofficial official website address:www.pushself.com The banner of baiyun.mobile.min.js simple effectsa simple banner effect:

Picture quality is not very high, or is the same picture, can you see? Can not see, can not look at the first to see it. is a simple few pictures of the carousel, here are a few different, read the code you should be able to find the problem.
HTML code:
<Divclass= "Mbslider">    <ul>        <Listyle= "Background:url (http://www.pushself.com/noImage.jpg) 50% 50% no-repeat;">            <ahref= "Http://www.pushself.com"></a>        </Li>        <Listyle= "Background:url (http://www.pushself.com/noImage.jpg) 50% 50% no-repeat;">            <ahref= "Http://www.pushself.com"></a>        </Li>        <Listyle= "Background:url (http://www.pushself.com/noImage.jpg) 50% 50% no-repeat;">            <ahref= "Http://www.pushself.com"></a>        </Li>    </ul></Div>
CSS code:
. Mbslider ul{position:relative;Z-index:0;Height:120px;Overflow:Hidden;}. Mbslider ul Li{position:Absolute;Top:0; Left:0;Z-index:0;Visibility:Hidden;}. Mbslider ul Li,. Mbslider ul a{Display:Block;width:100%;Height:100%;}. Mbslider ul li:nth-child (1){Visibility:Visible;}
JS Code: (The code is not very good, master passing remember to leave a bit of brilliant idea OH)
(function(i) {varWindowWidth =$ (window). Width (), WindowHeight=$ (window). Height (), name=Option.name, Automain=function() {             This. Mbslider =function() {                varMbsliderthis = This, Directionarr= ["Left" and "right"]; Lilength= $ ("." + name + "ul Li"). Length, Duration= I.durationinchDirectionarr?i.duration: "Left", Initval= I.initval && i.initval<lilength?parseint (i.initval): 0, Mbsliderheight= $ ("." + name + "UL")). Height (), Mbsliderheight= mbsliderheight > && mbsliderheight < windowheight/3?mbsliderheight:120; $("." + name + "ul"). Height (mbsliderheight);//banner can't be too big.                if(Lilength < 2) {                    return; }Else if(Lilength = = 2) {//easy to switch smoothly$ ("." + name + "ul"). Append ($ ("." + name + "UL").). HTML ()); Lilength= $ ("." + name + "ul Li"). length; }                varDirection =i.direction, T; Mbsliderthis.run=function(direction) {action.apply ( This,{                                0: Direction,1: Initval,2: Lilength,"Length": 3}) Initval= Initval = = lilength-1?0:++Initval; T= SetTimeout (function() {mbsliderthis.run (direction); },3000); }                $("." + name + "ul Li"). css ({"-webkit-transition-duration": I.duration + "S"                });                Mbsliderthis.run (direction); $("." + name + "ul Li"). Swipeleft (function() {                    varDirection = "Right";                    Clearinterval (t);                Mbsliderthis.run (direction);                }); $("." + name + "ul Li"). Swiperight (function() {                    varDirection = "Left";                    Clearinterval (t);                Mbsliderthis.run (direction);            });        }; }, Action=function(direction,initval,lilength) {varLilength =lilength; if(Direction = = "Right") {                varCurrlinum =Initval, Prevlinum= Currlinum = = 0?lilength-1:currlinum-1, Nextlinum= Currlinum = = Lilength-1?0:currlinum + 1; Directionval= 1; }Else {                varCurrlinum = Initval = = 0?0:-Initval, Prevlinum= Currlinum = = 0?-lilength + 1:currlinum + 1, Nextlinum= Currlinum = =-lilength + 1?0:currlinum-1; Directionval=-1; }            varPrevliwidth =-windowwidth *Directionval, Currliwidth= 0, Nextliwidth= WindowWidth *Directionval; $("." + name + "ul Li"). EQ (prevlinum). css ({"-webkit-transform": "Translate3d (" + prevliwidth + "px, 0, 0)",                "Visibility": "Hidden"            }); $("." + name + "ul Li"). EQ (currlinum). css ({"Visibility": "Visible",                "-webkit-transform": "Translate3d (" + currliwidth + "px, 0, 0)"            }); $("." + name + "ul Li"). EQ (nextlinum). css ({"-webkit-transform": "Translate3d (" + nextliwidth + "px, 0, 0)",                "Visibility": "Hidden"            }); }, Automain=NewAutomain (). Mbslider ();}) (option)
var option = {"Name": "Mbslider", "direction": "Right", "duration": ". 8", "Initval": 0};
In fact, there is a problem encountered, because there is in the PC to show the customer roughly, using background just to avoid dragging in some browsers when the picture is pulled out, but found a problem, background code: Background:url (/http www.pushself.com/noImage.jpg) 50% 50%/100% 100% no-repeat, under Chrome can be directly resolved to use, the mobile side is broken down, background-size:100%; Not background:100% 100%; When you first enter the page, or when you refresh, an unwanted effect appears.

This is the end of this share, I hope to have a lot of communication with you.
This article original blog address: http://www.cnblogs.com/unofficial official website address: www.pushself.com

A simple special effect caused by the Battle of the mobile development Why I gave up jquery mobile

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.