基于 Bootstrap 的 jQuery 表格插件,通过简单的设置,就可以拥有强大的单选、多选、排序、分页,以及编辑、导出、过滤(扩展)等等的功能。
Bootstrap 3 与 4 差别很大,目录文件结构、所引入的内容也不同,这里说说一下 Bootstrap 引入的文件、网页模板和兼容性问题。本网站刚刚搭建好,正好发一下文章原来测试网站。
1.gulp介绍 基于流的前端自动化构建工具,利用gulp可以提高前端开发效率,特别是在前后端分离的项目中。使用gulp能完成以下任务: 压缩html、css和js 编译less或sass等 压缩图片 启动本地静态服务器 其他 2.gulp构建 前端构建流程: 开发->分析->测试->编译->发布部署 一段简单的基于gulp的项目构建代码,gulpfile.js内容如下所示: gulp.task('default',function(){ return gulp .src(
做一个项目的时候 ,控制台总是会出现各种bug,其实不用慌张,终结起来也就几种类型的错误,在开发中每次遇到错误都善于总结,下次在看到就会胸有成竹知道是什么情况了,以下是在开发过程中总结的一些错误以及错
*bootstrap.css 是完整的bootstrap样式表,未经压缩过的,可供开发的时候进行调试用 *bootstrap.min.css 是经过压缩后的bootstrap样式表,内容和bootstrap.css完全一样,但是把中间不必要的空格之类的东西都删掉了,所以文件大小会比bootstrap.css小,可以在部署网站的时候引用,如果引用了这个文件,就没必要引用bootstrap.css了,下面的文件同样。
当前,前后端分离大行其道,我本人之前不少项目也是纯前后端分离,但总有些场景,春前后端分离整起来比较痛苦,比如我手头这个公众号项目吧,它涉及到第三方鉴权,第三方凭证,以及微信凭证这些,都不适合放到前端去做,外加一些本身业务层面的认证授权,这些终归是放服务端处理合适一些的。另一层面原因,是不想系统所有功能全怼到一个SPA中,还是希望不同功能模块,去拆分到不同页面中的, 俗称的多页。
部署前端之前,开发者通常会对代码进行打包压缩,这样可以减少代码大小,从而有效提高访问速度。然而,压缩代码的报错信息是很难Debug的,因为它的行号和列号已经失真。这时就需要Source Map来还原真实的出错位置了。
很早就开始跟着老师学习jQuery课程,那时候是要求熟练使用jQuery中的easyUI插件中的控件,包括textbox、combobox、panel、checkbox、tree、datagrid等等 总之是关于基本表单控件、树和一些图表统计的应用,当然,还有一些后台数据库的连接使用。当时几乎都在学着怎么用,竟然没有去仔细深入思考关于jQuery,并且对在头部(head中)引入的一些诸如jquery-1.4.4.min.js 文件也没有太大感觉。果然,在自己需要用jQuery做前端的时候一顿茫然。 这两天终
笔者增加Bootstrap 4 和 FontAwersome(字体图标),因为Bootsrap 4已经不再包含图标了。
Sentry 支持通过 source maps(源代码映射)对 JavaScript 进行 un-minifying,这允许您以原始的未转换形式查看从堆栈跟踪中获得的源代码上下文。这对于调试压缩后的代码(例如,UglifyJS)或从高级语言编译的代码(如 TypeScript 和 ES6)特别有用。
对于任何一个网站来说,优化页面的访问速度是必须的,个人来说,只要加载页面十秒以上或长时间处于空白或加载状态,我会立刻关掉此页面的。你又能容忍几秒呢?
Angular 2 已经发布了 2.1.2 版本, 相信很多人已经在使用(试用)了, 相比 AngularJS 1.x , Angular 2 在性能上有了长足的进步, 同时 Angular 2 也变得非常的庞大, 动辄几兆的脚本, 如何部署到生产环境? 接下来就介绍如何为生产环境编译 Angular 2 应用, 在本文中, 我们将 Angular 2 官方文档中的 Hello Angular 应用编译到 50K 以下, 以用于生产环境。
本文实例讲述了Yii2框架加载css和js文件的方法。分享给大家供大家参考,具体如下:
HTMLTestRunner 生成测试报告后,发现点击 view 这个按钮一直没有反应
随着网站功能逐渐丰富,网页中的js也变得越来越复杂和臃肿,原有通过script标签来导入一个个的js文件这种方式已经不能满足现在互联网开发模式,我们需要团队协作、模块复用、单元测试等等一系列复杂的需求。
注意:把css文件放在head中,js文件放在body的最下面,jquery在BP上面。
对于一份同逻辑的代码,当我们手写了一个个的文件,它们无论是 ESM 还是 commonJS 或是 AMD,他们都是 module; 当我们写的 module 源文件传到 webpack 进行打包时,webpack 会根据文件引用关系生成 chunk 文件,webpack 会对这个 chunk 文件进行一些操作; webpack 处理好 chunk 文件后,最后会输出 bundle 文件,这个 bundle 文件包含了经过加载和编译的最终源文件,所以它可以直接在浏览器中运行。 一般来说一个 chunk 对应一个 bundle,比如上图中的 utils.js -> chunks 1 -> utils.bundle.js;但也有例外,比如说上图中,我就用 MiniCssExtractPlugin 从 chunks 0 中抽离出了 index.bundle.css 文件。
(function() { var canvas = document.getElementById('quakeCanvas'); // Create our Planetary.js planet and set some initial values; // we use several custom plugins, defined at the bottom of the file var planet = planetaryjs.planet(); planet.loadPlugin(autocenter({extraHeight: -120})); planet.loadPlugin(autoscale({extraHeight: -120})); planet.loadPlugin(planetaryjs.plugins.earth({ topojson: { file: 'https://101.43.39.125/HexoFiles/js/planetaryjs/world-110m.json' }, oceans: { fill: '#001320' }, land: { fill: '#06304e' }, borders: { stroke: '#001320' } })); planet.loadPlugin(planetaryjs.plugins.pings()); planet.loadPlugin(planetaryjs.plugins.zoom({ scaleExtent: [50, 5000] })); planet.loadPlugin(planetaryjs.plugins.drag({ onDragStart: function() { this.plugins.autorotate.pause(); }, onDragEnd: function() { this.plugins.autorotate.resume(); } })); planet.loadPlugin(autorotate(5)); planet.projection.rotate([100, -10, 0]); planet.draw(canvas); // Plugin to resize the canvas to fill the window and to // automatically center the planet when the window size changes function autocenter(options) { options = options || {}; var needsCentering = false; var globe = null; var resize = function() { var width = window.outerWidth /2 + (options.extraWidth || 0); var height = window.outerHeight/2 + (options.extraHeight || 0); globe.canvas.width = width; globe.canvas.height = height; globe.projection.translate([width / 2, height / 2]); }; return function(planet) { globe = planet; planet.onInit(function() { needsCentering = true; d3.select(window).on('resize', function() { needsCentering = true; }); }); planet.onDraw(function() { if (needsCentering) { resize(); needsCentering = false; } }); }; }; // Plugin to automatically scale the planet's projection based // on the window size when the planet is initia
离线地图的核心其实就是拿到这些瓦片地图文件,并不是离线地图的代码怎么写,其实离线地图的网页代码和在线地图的网页代码几乎一致的,主要就是将对应的依赖的js文件从在线的地址改成本地的地址,然后可能多几个特殊的js文件用来本地交互,离线地图完全具备在线地图的大部分功能,离线地图有个好处就是可以离线使用,根本不需要联网,而且也不需要什么秘钥,你只要搞到那些瓦片地图文件就随便你怎么摩擦了。其实在线地图也是通过读取服务器上的离线地图文件加载到网页中的,你在快速的缩放和拖动地图的时候可以看到缝隙和空白,估计此刻就是在从服务器拉取瓦片地图文件来加载,而且这个服务器上的瓦片地图永远是最新的最完整的。
用了很久的自建 Ghost 博客系统不知道从哪个版本开始,页面加载速度忽然变慢了很多。看了下加载的资源,发现多了很多走 jsdelivr cdn 的资源,加载速度竟然长达半分钟。。。
使用CDN链接可以大大减小自己项目包的大小,把大部分的公共代码资源已经放在了云服务器上,只需要链接请求就可以。比如要引用jquery,可以自己下载jQuery.js文件导入,也可以直接导入一个链接,请求jQuery源代码。
真的,大家相信我,领导也要相信我,昨天下午我下班前运行之后报告还是很完美的,非常好的。
对于 react、react-router、redux、axios和antd等等这些不经常改动的库、我们让webpack不对他们进行打包,通过cdn引入,可以减少代码的大小、也可以减少服务器的带宽,网站首次加载会更快。
昨晚弄到三点就是为了 DIY 这 2 个页面,想给老婆一个浪漫的惊喜。 预览地址: 爱情纪念:http://zhangge.net/love 爱的故事:http://zhangge.net/love/forever 在线制作:http://zhangge.net/love/index.php 是别人的源码,没什么好说的,直接贴上作者说明: 一、超炫表白页面: 作者原话:为了预热情人节,麦葱二次开发了个表白程序。程序放在 BAE 上面,因为本地写这个原因,生成的页面过段时间就找不到了,导致链接页面 404,麦
BootStarp基本模版 <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="wi
最近在B站上看到杨旭老师的 ASP.NET Core 3.x 入门视频(完结)的第三节的ASP.NET视频教程,里面提到到ASP.NET Core 中的捆绑和缩小静态资产,可以在微软官方文档 ASP.NET Core 中的捆绑和缩小静态资产,特此记录一下,感兴趣的可以直接查看官方文档。
记住,依赖一定要安装在 devDependencies 下,否则会增大你的打包体积
YUI Compressor 是一个用来压缩 JS 和 CSS 文件的工具,采用Java开发。
这个系列的第一部分和第二部分,介绍了Javascript模块原型和理论概念,今天介绍如何将它们用于实战。 我采用的是一个非常流行的库require.js。 一、为什么要用require.js? 最早的时候,所有Javascript代码都写在一个文件里面,只要加载这一个文件就够了。后来,代码越来越多,一个文件不够了,必须分成多个文件,依次加载。下面的网页代码,相信很多人都见过。 <script src="1.js"></script> <script src="2.js"></scrip
最早的时候,所有Javascript代码都写在一个文件里面,只要加载这一个文件就够了。后来,代码越来越多,一个文件不够了,必须分成多个文件,依次加载。下面的网页代码,相信很多人都见过。
这个系列的第一部分和第二部分,介绍了Javascript模块原型和理论概念,今天介绍如何将它们用于实战。 我采用的是一个非常流行的库require.js。 一、为什么要用require.js? 最早的
今天的主要工作都在用react.js写一些前端界面,中间遇到了一些问题,这里解决这些问题的过程记录一下。 使用echarts图表组件 由于项目比较老旧,并没有使用webpack、gulp之类的前端编译工具进行编译,而是直接将依赖的javascript库引入,如下所示: <body> <script type="text/javascript" src="${ctx}/script/lodash/lodash.min.js"></script> <sc
引用JS报错Uncaught ReferenceError: $ is not defined如下图
YUI Compressor Maven插件可以压缩/合并js或css文件,经常用在Maven项目中,但最近发现在wabapp中执行了 mvn install 命令进行发布之后,终端中显示插件已经执行了压缩的动作,但在输出文件夹或者war包中js和css文件都还是未压缩的原始文件。
在项目的前端开发中,对于绝大多数的小伙伴来说,当然,也包括我,不可避免的需要在项目中使用到一些第三方的组件包。这时,团队中的小伙伴是选择直接去组件的官网上下载,还是图省事直接在网上搜索,然后从一些来源不明的地方下载,我们就无法管控了。同时,我们添加的组件间可能存在各种依赖关系,如果我们没有正确下载引用的话,到最后可能还是无法正常使用。
为什么慢?GFW屏蔽了google, 而stack overflow上用了一个js脚本,此脚本在谷歌服务器上。解决思路,就是让浏览器在本地加载此js脚本。访问速度直接从1.4min变到2s.
微信小游戏推出后,LayaAir引擎也同步支持了微信小游戏的开发,由于很多开发者对微信小游戏的开发流程不够了解,不太清楚如何下手。为此,我们在2018年的开工首日,从简介篇,小游戏创建篇,综合介绍篇三部分,全面介绍微信小游戏的开发、测试,与重要项目规则。
在做wiki文档的时候需要引入markdown编辑器,在此记录一下 django 中引入markdown编辑器 1. textarea 输入框 --> markdown编辑器 --- 首先,我这里是使用 Form生成的表单,markdown 编辑器实质上就是替换 Form生成的 TextAreaundefined models 如下: ```python content = models.TextField(verbose_name='内容') ``` 在前端页面中,使用 for循环生成,部分代码
在项目开发环境下,我们会把 JS 代码尽可能模块化,方便管理和修改,这就避免不了会出现一个项目自身 JS 文件数量达到 10 个或者更多。 而项目上线后,会要求将所有 JS 文件合并为 1 个或者几个,手动的操作虽然也不是问题,但每次修改更新都要手动操作合并一遍,这就肯定是个噩梦了。 这种情况下,一些工具也就随之产生,比如在线合并,一些网站提供js文件上传,然后合并,但这还是很麻烦,如果开发环境没有网络呢? 这会我就想到了 windows 系统下的 cmd 里的 copy 命令,它虽然是个复
还是那些传统的方式,一个页面从上到下引入几十个「js」文件,里面到处充斥着 jquery 的 DOM 操作,维护起来相当的糟糕,变量与函数之间跨文件引用。
去jQuery网站下载文件包,点击主页的“Download”之后,进入下载页面,可以选择production版本的进行下载,但是点击进去之后,浏览器并不会直接下载相关的文件,而是跳转到一个“密密麻麻”都是jQuery代码的页面,仔细查看浏览器地址栏中的url便可知,该页面其实就是jQuery的min版的文件,可以使用下面这种方法,下载jQuery文件:
head.jsp文件 将项目中所需要用到次数比较多的的插件,库等,同意放在一个jsp文件里面,命名为head.jsp文件,相当于一个全局的 <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib uri="
性能一直是项目中比较重要的一点,尤其门户网站,对页面的响应要求是很高的,从性能角度上来讲,对于Web端的优化其中重要的一点无疑是JS、CSS文件压缩,图片的融合,尽量减小文件的大小,必免占加载时占用过多的带宽。yuicompressor无疑是一个比较好的压缩工具,是yahoo的一个开源组件,下面介绍yuicompressor压缩JS、CSS文件,及在项目中的使用
在此之前我们已经编写了 Blog 的首页视图,并且配置了 URL 和模板,让 Django 能够正确地处理 HTTP 请求并返回合适的 HTTP 响应。不过我们仅仅在首页返回了一句话:欢迎访问我的博客。这是个 Hello World 级别的视图函数,我们需要编写真正的首页视图函数,当用户访问我们的博客首页时,他将看到我们发表的博客文章列表,就像 演示项目 里展示的这样。 首页视图函数 上一节我们阐明了 Django 的开发流程。即首先配置 URL,把 URL 和相应的视图函数绑定,一般写在 urls.py
在了解jQuery对象和JS对象之间的区别和转换前,我们先对jQuery框架进行一个简单的入门。
一般习惯于把引用的jquery.js 和 boostrap.js <body></body>标签中,bootstrap.css放在<style></style>标签中。
网页开发最最重要最最基本的就是富文本编辑器和文件上传,开始我迷信百度的ueditor和webupload,结果总是别扭,看来不能迷信BAT啊。富文本用了froala,文件上传早点用bootstrap fileinput那多炫啊。
Rollup是一个JavaScript模块打包器,它可以将多个模块打包成一个单独的文件,以便在浏览器中使用。与其他打包工具相比,Rollup的主要优势在于它可以生成更小、更快的代码。在本文中,我们将深入了解Rollup的工作原理、使用方法、摇树优化(tree shaking)。
图表作为一款用于可视化数据的工具,可以帮助我们更好的分析和理解数据,并发现数据之间的关系和趋势。下面以柱形图为例介绍如何使用JavaScript在报表中引入图表。
在搜索引擎中搜索关键字 .htaccess 缓存,你可以搜索到很多关于设置网站文件缓存的教程,通过设置可以将css、js等不太经常更新的文件缓存在浏览器端,这样访客每次访问你的网站的时候,浏览器就可以从缓存中获取css、js等静态文件,而不必从你的服务器再次下载读取,这样在一定程度上加快了网站的打开速度,又可以节约一下你的服务器流量。
领取专属 10元无门槛券
手把手带您无忧上云