Optimisation du code source de l'application est un travail très important de grosses applications. langage de programmation JavaScript, Ce problème devient plus important; par applications JavaScript et les applications Web, en particulier les applications Web 2.0 sont toujours limitées par les performances, la capacité des transformateurs et des navigateurs. applications web rendre les navigateurs prennent moins de ressources pour traiter, faire de la vitesse de réponse à l'action de l'utilisateur plus rapide. JavaScript article tutoriel vient autour de la conseils et astuces pour JavaScript jQuery codes.
- Demo
- Agrandir
- Recharger
- New window
G�n�rez vos vid�os d'entreprise par l'IA avec la voix ou simplement du texte
Votre premi�re application vid�o AI GRATUITE ! Automatisez votre premi�re vid�o AI. Cr�ez votre vid�o professionnelle en 5 minutes gr�ce � l'IA. Aucun �quipement ni comp�tence en montage vid�o requis. Production vid�o sans effort pour les sp�cialistes du marketing de contenu.
I have published several articles describing the many benefits we can all get from using jquery. Having access to many good plugins, examples and tutorials is important to get great ideas turned into excellent solutions as fast and elegant as possible and that is what jquery is all about. If you use jquery regularly or plan to start using it as more and more web developers tend to do I believe a few fundamentals and best practice tips to improve your jquery code will be worth spending a few minutes on. Please don’t hesitate to post a comment with your own tips and suggestions.
jQuery Tips
#1 – Load the framework from Google Code
Google have been hosting several JavaScript libraries for a while now on Google Code and you may want to load it from them instead of from your server.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
#2 – Storing Data
Use data method and avoid storing data inside the DOM. Some developers have a habit of storing data in the HTML attributes like fx.:
$('selector').attr('alt', 'data being stored'); // later the data can be retrieved using: $('selector').attr('alt');
HTML attributes is not meant to store data like that and the “alt” as a parameter name does not really make sense.
The right alternative in most cases is using the data method in jQuery. It allows you to associate data with an element on the page.
$('selector').data('paramtername', 'data being stored'); // then later getting the data with $('selector').data('paramtername');
This approach allows you to store data with meaningful names and it is more flexible as you can store as much data as you want on any element on the page. For more information about data() and removeData(), see here jQuery internals
One classical use of this is saving the default value of a input field because you want to clear it on focus.
<form id="testform"> <input type="text" class="clear" value="Always cleared" /> <input type="text" class="clear once" value="Cleared only once" /> <input type="text" value="Normal text" /> </form> $(function() { //Go through every input field with clear class using each function //(NB! "clear once" is two classes clear and once) $('#testform input.clear').each(function(){ //use the data function to save the data $(this).data( "txt", $.trim($(this).val()) ); }).focus(function(){ // On focus test for default saved value and if not the same clear it if ( $.trim($(this).val()) === $(this).data("txt") ) { $(this).val(""); } }).blur(function(){ // Use blur event to reset default value in field that have class clear // but ignore if class once is present if ( $.trim($(this).val()) === "" && !$(this).hasClass("once") ) { //Restore saved data $(this).val( $(this).data("txt") ); } }); });
#3 – Use Cheat Sheets
Most people can’t remember a lot of details and even though programmers tend to be better that the average the amount of information they need to have instant access too is devastating. Having a few cheat sheets printed out and placed next to the monitor is a good idea to speed up programming and to improve the code quality.
oscarotero jquery 1.3 (as wallpaper)
Quick reference to all jQuery 1.3 functions and properties. Note that it doesn't cover any of the UI functionality as this could easily be a whole cheat sheet in and of itself.
#4 – Minimize download time
Most browsers only download one script at the time and if you have several scripts being loaded on every page it can impact your download time.
You can use Dean Edwards service “packer” to compress your scripts and make download faster. You need to maintain a development version and a runtime version as all you in-line comments will be lost. You will find it here.
Another solution that take this to the extreme is interesting to take a look at. Basically it is a server based PHP script that combine javasctipt files and compress them in a easy to maintain approach. Take a look at and see if you can use the idea and some elements of the concept “Make your pages load faster by combining and compressing javascript and css files“.
#5 – Logging to the Firebug console in jQuery
Firebug is one of my favourite Firefox extensions providing tons of tools in a very usable structure to aid you in HTML+CSS+JavaScript development. Obviously it is worth having just for it’s excellent inspection feature allowing you to jump into the html and css and learn in a visual way what elements of the page is rendered by what code. As a jQuery and general Javascript developer Firefox also has good support for logging in your JavaScript code.
The easiest way to write to the Firebug console looks like this:
console.log("hello world")
You can pass as many arguments as you want and they will be joined together in a row, like
console.log(2,4,6,8,"foo",bar)
As a jQuery developer it even gets better using a tiny extension that Dominic Mitchell came up with to log any jQuery object to the console .
jQuery.fn.log = function (msg) { console.log("%s: %o", msg, this); return this; };
With this extension you can simply call .log() on the object you are currently addressing fx.:
$('#some_div').find('li.source > input:checkbox') .log("sources to uncheck") .removeAttr("checked");
- Sent (0)
- Nouveau
Générez vos vidéos d'entreprise par l'IA avec la voix ou simplement du texte
chatGPTaz.com
Parlez à ChatGPT dans votre langue maternelle
AppAIVidéo
Votre première application vidéo AI GRATUITE
Deepfake Video
Deepfake AI Video Maker
Deepfake
Deepfake AI Video Maker
AI Deep Fake
Deepfake AI Video Maker
AI Voice Generator
Most Realistic Text to Speech AI Solutions
AI Voice Generator
Most Realistic Text to Speech AI Solutions
AIvidio
AI Video Mobile Solutions
AIvideos
AI Video Platform & Solutions
AIvedio
AI Video App Maker
Artificial General Intelligence
Ai and higher level Artificial General Intelligence (AGI)
Artificial General Intelligence
Ai and higher level Artificial General Intelligence (AGI)
Faceswap AI en ligne
Échangez des visages, des vidéos, des photos et des GIF instantanément avec de puissants outils d'IA - Faceswap AI Online GRATUIT
Faceswap AI en ligne
Échangez des visages, des vidéos, des photos et des GIF instantanément avec de puissants outils d'IA - Faceswap AI Online GRATUIT
Faceswap AI en ligne
Échangez des visages, des vidéos, des photos et des GIF instantanément avec de puissants outils d'IA - Faceswap AI Online GRATUIT
Powerful AI Presentation PPT Maker for FREE
Build an impressive presentation with our free online AI presentation app
Your next top AI Assistant
Claude AI, developed by Anthropic
Your next top AI Assistant
Claude AI, developed by Anthropic
Temu gratuit 500 $ pour les nouveaux utilisateurs
Claim Free Temu $500 Credit via Affiliate & Influencer Program
Crédits publicitaires TikTok gratuits
Maîtrisez les publicités TikTok pour le marketing de votre entreprise
Crédits publicitaires TikTok gratuits
Maîtrisez les publicités TikTok pour le marketing de votre entreprise
Dall-E-OpenAI.com
Générez automatiquement des images créatives avec l'IA
chatGPT4.win
Parlez à ChatGPT dans votre langue maternelle
Premier produit d'intelligence artificielle d'Elon Musk - Grok/UN.com
Parlez au chatbot Grok AI dans votre langue
Outily.win
Centre d'outils ouvert et gratuit, utilisable par tous et pour tous, avec des centaines d'outils
GateIO.gomymobi.com
Airdrops gratuits à réclamer et à partager jusqu'à 150 000 $ par projet
iPhoneKer.com
Économisez jusqu'à 630 $ à l'achat d'un nouvel iPhone 16
Acheter le robot Tesla Optimus
Commandez votre robot Tesla Bot : Optimus Gen 2 dès aujourd'hui pour moins de 20 000 $