Speed up websites

From LemonWiki共筆
Revision as of 10:30, 4 April 2026 by Planetoid (talk | contribs) (→‎Image part)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Measuring[edit]

Mobile friendliness tool

Image Compression[edit]

Compression tools to reduce the file size of images

ImageMagick:

magick input.jpg -resize 2000x2000\> output.jpg

ImageMagick \>: shrinks only, never enlarges — both dimensions scale proportionally

ffmpeg:

ffmpeg -i input.jpg -vf "scale=2000:-1:force_original_aspect_ratio=decrease" output.jpg

# To cap the longer edge at 2000
ffmpeg -i input.jpg -vf "scale=2000:2000:force_original_aspect_ratio=decrease" output.jpg

ffmpeg

  • scale=2000:-1: -1 already preserves aspect ratio; force_original_aspect_ratio=decrease ensures the longer edge never exceeds 2000, with the shorter edge calculated automatically
  • To cap both width and height at 2000 (e.g. for portrait images): scale=2000:2000

JavaScript part[edit]

Compression tools to reduce the file size of javascript

Using CDN (Content Delivery Network)

//If the javascript library hosted at CDN was failed to connect, it will switch to local javascript file automatically.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js" type="text/javascript"></script>
<script>!window.jQuery && document.write('<script src="local-js-path/jquery-1.12.4.min.js"><\/script>');</script>

<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js" type="text/javascript"></script>
<script>!window.jQuery.ui && document.write('<script src="local-js-path/jquery-ui-effects.custom-1.9.2.min.js"><\/script>');</script>
	


Web site design and development process


Connection test[edit]

網路服務連線測試

References[edit]