小编Cas*_*sen的帖子

优化HTML表格?

我有一个很大的HTML表(2000多行),我注意到我使用的悬停似乎没有响应(需要大约1秒触发).

#songs tbody tr:hover td { color: #1abc9c; }
Run Code Online (Sandbox Code Playgroud)

我需要在DOM中加载所有元素的表.它们本身不一定是可见的,因此延迟加载是一种选择,但是当用户向下滚动很多时,他仍然会遇到问题.

有没有办法优化HTML(表格),我应该注意什么?

编辑

我决定在其他浏览器中试用它,Firefox似乎根本没有任何问题,IE10也没有.所以这是我在Chrome中唯一的问题.

<tr data-playlist="/edm" data-filename="Chuckie - Together (Original Mix).mp3" class="song match">
    <td>Together (Original Mix)</td>
    <td>Chuckie</td>
</tr>
Run Code Online (Sandbox Code Playgroud)

另请注意,它不是关于页面加载,而是在一秒钟内加载.问题是.song:hoverChrome中的CSS .

编辑2:使用Chrome开发人员工具进行性能测试

所以我决定看一下Developer工具来调试这个问题."个人档案"选项卡没有让我更进一步,但是当我尝试时间轴事件时,我发现当我将鼠标悬停在一行上时会发生以下情况:

在此输入图像描述

html css performance

7
推荐指数
1
解决办法
2051
查看次数

Socket.io客户端javascript文件位置(使用nginx反向代理)

我正在尝试在同一服务器/端口上运行多个NodeJS应用程序,使用nginx作为代理实际运行的Node应用程序的反向代理.

server {
    listen       8000;
    server_name  node.domain.com;
    root         /var/www/node;

    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_set_header X-NginX-Proxy true;

    # Enables WS support
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_redirect off;

    location / {
        proxy_pass http://127.0.0.1:8001;
    }

    location /irc/ {
        proxy_pass http://127.0.0.1:8002;
    }

    location /voidwalker/ {
        proxy_pass http://127.0.0.1:8003;
    }
}
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,我forever在不同的子目录中运行(使用)不同的项目(NodeJS应用程序)/var/www/node.

但我想在我的一个项目中使用socket.io.在socket.io文档中,它声明我应该使用<script src="/socket.io/socket.io.js"></script>在客户端加载socket.io-client,它返回404:

GET http://node.domain.com/socket.io/socket.io.js 404 (Not Found)
Run Code Online (Sandbox Code Playgroud)

我猜这是因为我正在代理请求但我并不完全理解这个过程在内部是如何工作的,我希望能够让它发挥作用.

关于这一点需要注意的是我必须使用<link rel="stylesheet" href="/voidwalker/css/main.css">加载我的CSS,而我宁愿使用<link rel="stylesheet" href="/css/main.css">以防我想在特定的子域/其他域上部署它(因为这是一个开发服务器). …

reverse-proxy nginx node.js

5
推荐指数
1
解决办法
1819
查看次数

Access-Control-Allow-Origin错误但请求通过

我目前正在为我的实时服务器部署一个基本的API,而且我遇到了(我认为)一个CORS问题,但是有一些行为正在进行,我无法解释.

我正在从AngularJS前端到Laravel 5(+ laravel-cors)后端进行通信.

我开始使用简单的jQuery AJAX调用进行测试(下面),当我从我的本地Vagrant环境(http://dev.example.local/test.html)发出请求时,http://api.example.com/v1/matches我得到一个错误Access-Control-Allow-Origin.奇怪的是,请求确实通过,因为信息正确地通过基于Laravel的API存储在数据库中.

$.ajax({
    method: 'POST',
    url: 'http://api.example.com/v1/players',
    data: {
        "username": "username",
        "first_name": "First",
        "last_name": "Last",
        "nickname": ""
    }
}).always(function(r) {
    console.log(r);
});
Run Code Online (Sandbox Code Playgroud)

错误:

XMLHttpRequest cannot load http://api.example.com/v1/players. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://other.example.com' is therefore not allowed access.
Run Code Online (Sandbox Code Playgroud)

console.log(r)收益{readyState: 0, responseJSON: undefined, status: 0, statusText: "error"}

我使用Homestead VM(API)和Vagrant环境(应用程序)在本地开发了应用程序,它在这些环境中正常工作......

一些观察:

  • 这些请求中的每一个都显示在我的Chrome开发者工具中的方法:POST,状态:200 OK,类型:xhr
  • 像Postman和PhpStorm的RESTful服务测试器这样的工具正确执行请求,并且数据添加没有错误.

关于如何进一步调试这个问题的任何想法都是受欢迎的......我一直试图整理这一整天,我只是不知道是什么导致了它.

cors angularjs laravel-5

4
推荐指数
1
解决办法
4355
查看次数

PHP glob/scandir和Linux软链接/权限

我正在尝试编写一个简单的在线音乐播放器来改进我的编程.

我有一台运行CentOS 6.5的服务器,外部硬盘包含我的所有文件.我安装了我的存储分区/mnt/storage,我的音乐在/mnt/storage/cascornelissen/Muziek,它具有以下权限:

drwxrwxr-x 19 cascornelissen ftpusers       4096 Nov  4 14:43 Muziek
Run Code Online (Sandbox Code Playgroud)

然后我有一个简单的httpd网络服务器,托管项目/var/www/html/melodi,它保存了前面提到的Muziek目录的软链接:

lrwxrwxrwx 1 root           ftpusers   34 Jan 26 22:31 music -> /mnt/storage/cascornelissen/Muziek
Run Code Online (Sandbox Code Playgroud)

我想使用PHP glob列出所有文件,但返回一个空数组.所以我试过,scandir("music")但它返回以下错误:

Warning: scandir(music): failed to open dir: Permission denied in /var/www/html/melodi/index.php on line 42
Run Code Online (Sandbox Code Playgroud)

有关如何解决此权限问题的任何想法?

php apache permissions symlink

2
推荐指数
1
解决办法
1956
查看次数

AngularJS嵌套$ http调用

我正在尝试编写一个从两个源获取数据的工厂,并使用一个源来扩展另一个对象中的数据.

app.factory('information', ['$http', '$q', 'players', 'matches', function($http, $q, players, matches) {
    return {
        // Returns all matches and players including extra parsing
        get: function() {
            return players.get().success(function(data) {
                players = data;

                matches.get().success(function(data) {
                    matches = data;

                    for ( match in matches ) {
                        matches[match].a_player1 = players.filter(function(player) { return player.username == matches[match].a_player1 })[0];
                        matches[match].a_player2 = players.filter(function(player) { return player.username == matches[match].a_player2 })[0];
                        matches[match].b_player1 = players.filter(function(player) { return player.username == matches[match].b_player1 })[0];
                        matches[match].b_player2 = players.filter(function(player) { return player.username == matches[match].b_player2 })[0];
                        console.log(matches) …
Run Code Online (Sandbox Code Playgroud)

angularjs

2
推荐指数
1
解决办法
4561
查看次数