Html HTML5 Shim 与 Shiv
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14429061/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
HTML5 Shim vs. Shiv
提问by owlstone
Beginner at Rails.
Rails 初学者。
I'm coding CSS in my sample application. I understand there is Javascript code to help browsers, i.e. Internet Explorer, support HTML5.
我正在我的示例应用程序中编写 CSS。我知道有 Javascript 代码可以帮助浏览器,即 Internet Explorer,支持 HTML5。
What is the difference between HTML5 Shim and HTML5 Shiv? Is it something worth knowing?
HTML5 Shim 和 HTML5 Shiv 有什么区别?有什么值得了解的吗?
http://html5shim.googlecode.com/svn/trunk/html5.js
http://html5shim.googlecode.com/svn/trunk/html5.js
http://html5shiv.googlecode.com/svn/trunk/html5.js
http://html5shiv.googlecode.com/svn/trunk/html5.js
My code, y'all:
我的代码,你们:
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js">
</script>
<![endif]-->
回答by Norguard
It was originally called the html5-shiv.
它最初被称为 html5-shiv。
Shiv really isn't the right term, as a shiv is a stabbing-implement.
Shiv 真的不是正确的术语,因为 shiv 是一种刺刀。
A shim is something which you use to level things out (or prop them up). If a table has one leg that's too short, you might shim it with a piece of wood or a phone book...
垫片是您用来平整(或支撑它们)的东西。如果桌子的一条腿太短,你可以用一块木头或电话簿来垫它......
So html5-shim is for people who expect html5shiv to be called a shim.
所以 html5-shim 是为那些希望 html5shiv 被称为 shim 的人准备的。
That's entirely it, as far as differences go.
就差异而言,仅此而已。
Kind of like polyfill
s cover over the differences in implementations of features.
In North America, Polyfill might be called "Spackle".
有点像polyfill
s 涵盖了功能实现的差异。
在北美,Polyfill 可能被称为“Spackle”。
回答by Sander Luís
From http://code.google.com/p/html5shim/
来自http://code.google.com/p/html5shim/
shiv or shim?
Common question:what's the difference between the html5shim and the html5shiv?
Answer:nothing, one has an m and one has a v - that's it.
shiv 还是 shim?
常见问题:html5shim 和 html5shiv 有什么区别?
答案:没有,一个有 m,一个有 av - 就是这样。
回答by Adriano Rosa
The answer is.
答案是。
The term shiv originates from John Resig, who was thought to have used the word for its slang meaning, a sharp object used as a knife-like weapon, intended for Internet Explorer. Truth be known, John probably intended to use the word shim, which in computing means an application compatibility workaround. Rather than correct his mispelling, most developers familiar with Internet Explorer appreciated the visual imagery. And that, kids, is etymology.
shiv 一词起源于John Resig,他被认为是用这个词来表示它的俚语意思,一种用作刀状武器的锋利物体,用于 Internet Explorer。说实话,John 可能打算使用shim一词 ,这在计算中意味着应用程序兼容性变通方法。大多数熟悉 Internet Explorer 的开发人员并没有纠正他的拼写错误,而是欣赏视觉图像。孩子们,这就是词源。
From author's page at https://github.com/aFarkas/html5shiv
回答by Travis Heeter
This is probably more simple than you're looking for, but for others who may be confused:
这可能比您想要的更简单,但对于其他可能会感到困惑的人:
First, here's a non-programming definition of a Shim:
首先,这是一个 Shim 的非编程定义:
noun: a washer or thin strip of material used to align parts, make them fit, or reduce wear.
verb: wedge (something) or fill up (a space) with a shim.
名词:用于对齐零件、使它们贴合或减少磨损的垫圈或薄条材料。
动词:用垫片楔入(某物)或填满(空间)。
To understand a shim in programming terms, you need to understand what a pain IE was/is for web developers:
要理解编程术语中的 shim,您需要了解 IE 对 Web 开发人员来说是什么痛苦:
IE was one of the first commercially-available web browsers. And it may have been the first one available "for free". Thus, it was built before browser standards were defined, ie definitions of how to handle html and javascript.
IE 是最早的商用 Web 浏览器之一。它可能是第一个“免费”可用的。因此,它是在定义浏览器标准之前构建的,即如何处理 html 和 javascript 的定义。
So, in order to keep sites and applications working in IE, as standards were produced, IE could not or (for monopolistic reasons) would not update IE (here's a great post with more info about that). This caused a rift between IE and other browsers that grew over time. This rift often surfaced in unexpected errors, styling differences, and some applications straight-up refused their users the option of running it from other browsers.
因此,为了使站点和应用程序在 IE 中正常工作,随着标准的制定,IE 不能或(出于垄断原因)不会更新 IE(这是一篇包含更多相关信息的精彩帖子)。这导致 IE 和其他浏览器之间的裂痕随着时间的推移而增长。这种裂痕经常出现在意外错误、样式差异以及一些应用程序直接拒绝用户从其他浏览器运行它的选项中。
But, if a product was going to be available for both types of browser, developers often had to write two sets of code. One for practically every modern browser, and one for IE. Obviously, this practice made upkeep a nightmare. But, as time progressed, many JavaScript frameworks/libraries started adding code to specifically address these issues. These pieces of code are known as shims. Because they're making your code "fit"in IE.
但是,如果产品要同时适用于两种类型的浏览器,开发人员通常必须编写两套代码。一种适用于几乎所有现代浏览器,一种适用于 IE。显然,这种做法使维护成为一场噩梦。但是,随着时间的推移,许多 JavaScript 框架/库开始添加代码来专门解决这些问题。这些代码片段称为垫片。因为他们让你的代码“适合”在 IE 中。
For instance, when jQuerywas first released, a major advantage it had over its predecessors - or just writing your own library - was that it worked in every Browser, even IE. At the time IE was still heavily used, so this saved developers a lot of time. But now jQuery is on version 3. And the major difference between previous versions is that it no longer supports IE. That's because everyone, even Microsoft has sorta moved away from IE (Win10's default browser is Edge). But, unfortunately many sites and web applications were designed specifically for IE (for security reasons). And even though IE has gone the way of the Dodo for most commercial applications, it still offers security features that other browsers don't (but they're catching up quickly). And even if they did, the cost of updating these applications is often too great to be justifiable.
例如,当jQuery首次发布时,它相对于其前辈——或者只是编写自己的库——的一个主要优势是它可以在每个浏览器中运行,甚至 IE。当时 IE 仍然被大量使用,因此这为开发人员节省了大量时间。但是现在 jQuery 是第 3 版。与以前版本之间的主要区别是它不再支持 IE。那是因为每个人,甚至微软都已经远离了 IE(Win10 的默认浏览器是 Edge)。但是,不幸的是,许多站点和 Web 应用程序是专门为 IE 设计的(出于安全原因)。尽管 IE 在大多数商业应用程序中已经采用 Dodo 的方式,但它仍然提供其他浏览器没有的安全功能(但它们正在迅速赶上)。即使他们这样做了,更新这些应用程序的成本通常也太高了,是不合理的。
And that basically means many people still are forced to use IE, so these shims are still necessary.
这基本上意味着许多人仍然被迫使用 IE,所以这些垫片仍然是必要的。