Application of JavaScript-based framework (library)

jQuery framework

  • jQuery uses CSS selectors to access and manipulate HTML elements (DOM objects) on web pages
  • jQuery provides both user interface and plugins
  • The main jQuery function is: $ ()

Use jQuery library in JS

<!DOCTYPE html>
<html>
<head>
<script
src="//libs.baidu.com/jquery/1.8.3/jquery.min.js">
</script>
<script>
function myFunction()
{
$("#h01").attr("style","color:red").html("Hello jQuery")
}
$(document).ready(myFunction);
</script>
</head>
<body>
<h1 id="h01"></h1>
</body>
</html>

Prototype framework

  • Simple API for performing common web tasks
  • A library containing attributes and methods for manipulating HTML DOM
  • Prototype provides functions to make HTML DOM programming easier
  • The main Prototype function: $ ()
  • The $ () function accepts the id value (or DOM element) of the HTML DOM element and adds new functionality to the DOM object

Use Prototype library in JS

<!DOCTYPE html>
<html>
<script
src="//apps.bdimg.com/libs/prototype/1.7.1.0/prototype.js">
</script>
<script>
function myFunction()
{
$("h01").writeAttribute("style","color:red").insert("Hello Prototype!");
}
Event.observe(window,"load",myFunction);
</script>
</head>
<body>
<h1 id="h01"></h1>
</body>
</html>

CDN-Content Distribution Network

CDN (Content Delivery Network) contains a network of servers that can share code bases.
Solve the problem:
I hope the web page can be as fast as possible, the capacity of the page is as small as possible, and I want the browser to cache as much as possible. If many different websites use the same JavaScript framework, then put the framework inventory A common location for every web page to share.

Published 89 original articles · praised 83 · views 3499

Guess you like

Origin blog.csdn.net/devin_xin/article/details/105270455